riedelinho
riedelinho

Reputation: 414

How to access request Header, or HTTPServletRequest on Apache ISIS DomainService?

I have an apache ISIS webapplication with several Objects and RestfulServices. For logging-purposes i need some information of the request itself, not only the parameters which should be send. How can I access these Request-Header information?

I tried to get the HttpServletRequest via the RequestCycle object. Here is the code-line:

HttpServletRequest req = (HttpServletRequest) RequestCycle.get().getRequest().getContainerRequest();

When I create the objects via apache wicket viewer I get access to the HttpServlerRequest object and all the information of the request. But when I send the a request via the restful services I get a NullpointerException when I try to access the RequestCycle.

Do you have any idea how to access the request header in this domainservice?

Thanks for your help.

Upvotes: 2

Views: 533

Answers (2)

Dan Haywood
Dan Haywood

Reputation: 2235

If all you require is the Accept headers, then you can use the AcceptHeaderService.

If you need access to anything else then you'll have to roll-your-own. But doing so should be quite easy; take a look at the implementation of aforementioned AcceptHeaderService along with where it is registered in RestfulObjectsApplication; you could provide a custom subclass of RestfulObjectsApplication in the web.xml.

Upvotes: 2

martin-g
martin-g

Reputation: 17513

When you request with Restful services there is no Wicket RequestCycle at all because WicketFilter is not used for Restful requests.

I cannot help with the rest of the question. I have no experience with this.

Upvotes: 2

Related Questions