Interceptors and Apache Camel - interceptor

I am new to camel so my question is how to get request and responce values that is displayed on saop UI to the log file using Interceptors configuration. I need to apply some interceptor configuration before the request hit to camel so that we can filter the request object and same with the responce.

Look at logging interceptors in camel cxf endpoint declaration : inInterceptors
http://camel.apache.org/cxf.html
Or
You can just print the request inside your route as well using ${body}

Add this to your route configuration:
interceptFrom()
.when(exchange -> isToBeIntercepted(exchange)) //which routes are to be intercepted
.process(doSomeStuffHere());

Related

How to solve json-server custom route error?

I am using json-server to get a fake REST API.
I have added the following custom route in my routes.json file.
{
"/admin/posts/edit/:id": "/posts/:id"
Based on the custom route, a PUT request to /admin/posts/edit/2 should go to /posts/2. But the request is being sent to /posts.
What am I doing wrong? I want the request to go to /posts/2.

firebase receive JSON via HTTP request

firebase:
how to get remote config information via HTTP in the form of a JSON request, without modules?
enter image description here
Firebase Remote Config provides REST endpoints you can use to get your project's remote config. See https://firebase.google.com/docs/reference/remote-config/rest

Artemis mqtt client interceptor: java.lang.ClassNotFoundException

I want to intercept message send by a mqtt client to artemis broker.
I am following the example "interceptor-client-mqtt".
My problem is that I am always getting an error "java.lang.ClassNotFoundException: SimpleMQTTInterceptor".
My question is where should I put the interceptor class so that the broker could find it?
Should I put only the class of the interceptor, or should I put a jar file?
Put your interceptor class in a jar in the broker's "lib" directory.

Remove 'Server' http header from api response

I have an application which uses camel-jetty, camel-cxf to expose a REST api and runs in apache karaf (fuse esb). Because of security reasons, I need to remove 'Server' header from API response. I removed the header from camel exchange headers but still it returns in api response as Jetty(7.6.7.v20120910). How can I remove the header from API response ?
The jetty component, you can turn off sendServerVersion by setting sendServerVersion=false in the endpoint uri.
For Apache CXF or camel-cxf I am not sure if that is possible. You would need to check Apache CXF documentation.
I added following line to jetty.xml and got server header removed.
<Set name="sendServerVersion">false</Set>

grails REST API with Spring Security core and CORS plugins not working for OPTIONS http method requests

Trying to do cross-domain request [CORS] from AngularJS front-end to Grails 2.3.1 RESTful Service on other server.
AngularJS sends OPTIONS http request first for any cross-domain requests.
To support this, I added following method to my Controller that extends RestfulController
static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE", options: "OPTIONS", trace: "TRACE", head: "HEAD"]
#Secured(value=['permitAll'], httpMethod='OPTIONS')
def options() {
log.debug("i am in options method")
response.setHeader("Allow", "GET,POST,PUT,DELETE,OPTIONS,TRACE,HEAD")
return
}
For cURL command bellow, my options() method on my Controller never getting called. curl always gets 301 response.
curl -H "Origin: http://example.com" -X OPTIONS --verbose http://localhost:8080/Console/tenants/1/spaces.xml
Is this a bug in Spring Security core plugin or am I missing something?
My environment consists, Grails 2.3.1, Spring Security Core and ACL 2.0-RC1 plugins and CORS plugin 1.1.1
That's because the browser checks for cross domain requests before your action. You can do that using a servlet filter, or just use the CORS Grails plugin.
using latest CORS Grails plugin solves the problem. It includes a filter that intercept OPTIONS request and provide the response.

Resources