New to APIM. Trying to change the exposed querystring parameter name (not the value) with a different name that the backend api expects
For example, APIM endpoint expects /v1/Customer?CustomerId=123
I think I need to use rewrite-url policy on the inbound section?
To change it to this: /v1/Customer?ExternalCustomerId=123
Was trying this, doesn't work
<set-query-parameter name="ExternalCustomerId" exists-action="append">
<value>#(Context.Request.QueryString["CustomerId"])</value>
</set-query-parameter>
Error: The name 'Context' does not exist in the current context
This has changed as of september 2019. now use the following:
<set-query-parameter name="ExternalCustomerId" exists-action="append">
<value>#(context.Request.Url.Query.GetValueOrDefault("CustomerId"))</value>
</set-query-parameter>
Try lower case "context". Plus QueryString is a IReadOnlyDictionary as described here: https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables, but there is a handy overload:
<set-query-parameter name="ExternalCustomerId" exists-action="append">
<value>#(context.Request.QueryString.GetValueOrDefault("CustomerId"))</value>
</set-query-parameter>
Related
I just want to make a crud api over an "Event" object. Routes for
index works well but the route for an specific event doesn't work
as expected
this is what I have in 'routes.php'
$app->get('/event/:id', \App\Handler\EventRecoverHandler::class, 'event.withId');
I expect to recover the id in the handler using:
$id = $request->getAttribute('id');
but the route only get recognized if I put '/events/:id' literally, in this case the handler is reached but the id is null (as expected)
on the other hand if I put '/events/4' the result is: "Cannot GET http://localhost/event/4"
The problem was that I was following the examples provided in routes.php file, they say that in order to use route parameters you should use /path/:parameter
i don't know what router packages does use this sintax but
in my case I was using FastRoute (the default zend expressive installer selection)
and the right sintax is (following fast route documentation)
/path/{parameter}.
AWS API Gateway service page says that a Template Selection Expression can be used to implement a way to transform the request body. However the documentation for these selection expressions is very light and I haven't been able to find any examples.
Where can I find examples of what these expressions look like?
Where can I find what variables and options are available in these expressions?
To add content to the integration request, you'll need to use a Request Template. The Request Template is the piece that actually generates the new request body, while the Request Selection Template is used in the process of determining which Request Template to use.
Turn off HTTP Proxy Integration for your route. (You can't modify the request otherwise.)
Save your changes. (the Request Templates section won't appear until you do so.)
Set your Template Selection Expression. This is used to look up a value from the incoming request object. (If you want to match all incoming requests, enter \$default. Note the slash. Full documentation here.)
Set your Template Key. This is compared against the value selected by the Template Selection Expression. If it's a match, the template is used. (If you want to match all incoming requests, enter $default. Note the absence of a slash.)
Click your Template Key to open the template editor. This is where you enter your template that will be sent to your integration endpoint as the body of the request. For example, if you want to forward the connection ID and the incoming query parameters to the integration endpoint, you can use the following:
{
"myConnectionIdProperty": "$context.connectionId",
"myQueryParams": $input.params()
}
Documentation for variables available to you in the template expression can be found here.
(Note that while $request is a valid variable in the Template Selection Expression, it is not a valid variable in the template itself. Use $input instead there.)
Basically Template Selection Expression works same as Route Selection Expression. All examples for Route Selection Expression will work.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-selection-expressions.html#apigateway-websocket-api-route-selection-expressions
In addition to it, TemplateSelectionExpression for integration response supports few more variables:
$integration.response.statuscode
$integration.response.header.headerName
$integration.response.multivalueheader.headerName
I have an interface with methods foo() and bar() that I'd like to go to endpoints direct:foo and direct:bar. In the proxy configuration you are only allowed to enter one endpoint and I have not found any way to get the name of the method called in code to be able to route based on that name.
Am I missing some document somewhere?
Look at the info at http://camel.apache.org/message-endpoint.html related to 'toD'
I think you are using a Camel version > 2.15
Revert to old behaviour which does not bind parameters to body and then you will have accesso to BeanInvocation object that will tell you which method was called.
// Create Proxy
MyAuditService service = new ProxyBuilder(context)
.endpoint("direct:analyzeMethodCall") // dispatcher endpoint
.binding(false) // false: gives you BeanInvocation, true gives you parameter
.build(MyAuditService.class);
Then in your route from direct:analyzeMethodCall use a Processor to analyze the BeanInvocation object and call direct:foo or direct:bar. You must set the body explicitly.
Can I explicitly specify the particular policy to use along with the method, instead of using the policy that pertains to the object of the second parameters?
I would like to do something like this:
$this->authorize('FeatureNamePolicy', 'isEnabled');
the parameters are:
Name of the policy
Method of the policy
Instead of using the parameters:
Method name within the policy
Object (determines the policy used)
I did it with this
$this->authorize('featureIsEnabled', sheetPolicy::class);
In my team we have coding rule that requires that every function's parameter starts with prefix, e.g. *p_someParam*.
With Web Api if we want to request a GET function that takes two parameters, we should add those parameters like "...?p_firstParam=value1&p_secondParam=value2".
Is there some way to use in requests more user-friendly names, like someParam without prefix, that will automatically map to parameters in controller's action? Maybe there is some attribute to rename action parameters? I couldn't find any similar example.
Every clue is appreciated.
I think you looking for URL rewriting, in that you need to map the urls to config or programmatic
http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET nice article to follow, its in ASP.Net,