简体   繁体   中英

Adding response header in JAX-RS request filter

I'm implementing rate limit filter in JAX-RS application (Websphere Liberty).

Main functionality will be in request filter (implementing ContainerRequestFilter interface), so I can deny request before it reaches endpoint.

However, I would also like to add response headers at the same time (eg X-RateLimit-Limit) in any case.

I would like to avoid writing separate ContainerResponseFilter for this purpose because performance reasons. I have all counters loaded already in Request filter.

Is there a clean way to include response headers in request filter for inclusion down the chain?

Solved by passing data in requestContext from request to response filter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM