Knotx / knotx

Knot.x is a highly-efficient and scalable integration framework designed to build backend APIs
https://knotx.io
Apache License 2.0
126 stars 26 forks source link

Treat additional knotx-params in template as service request parameters #298

Closed rkarwacki closed 7 years ago

rkarwacki commented 7 years ago

Currently, as described in the documentation, there is a possibility to define custom query parameters from configuration files.

This solution is not flexible, because it is not possible to change the parameters without re-configuring Knot.X.

Consider this snippet (using un-escaped quotes indata-knotx-params for readability, instead of "):

<script data-knotx-knots="services,handlebars" data-knotx-service="parametrized-service"
                data-knotx-params="{'parameter1': 'value1','parameter2': 'value2'}"
                type="text/knotx-snippet">

And configuration fragment:

{
  "name": "parametrized-service",
  "address": "knotx.adapter.service.http",
  "params": {
    "path": "/external/service"
  }
}

The presented fragment should cause a call to:

/external/service?parameter1=value1&parameter2=value2

What is essential, in this approach we can change the parameter value dynamically using an outside system:

data-knotx-params="{'items': '${model.numberOfItemsToBeLazyLoaded}'}"
malaskowski commented 7 years ago

Hi @rkarwacki , please see #296 . This feature adds possibility to pass additional query parameters and headers to the service (also via data-knotx-params).