All Products
Search
Document Center

Custom Filter of REST

Last Updated: Aug 17, 2020

For the RESTful service, we have designed a JAXRSProviderManager class that becomes valid on the server when the service is started.

  1. com.alipay.sofa.rpc.server.rest.RestServer#registerProvider

You can register a custom Filter class by calling the following class after initialization.

  1. com.alipay.sofa.rpc.config.JAXRSProviderManager#registerCustomProviderInstance

The custom Filter follows the REST specification.You need to implement the following interface:

  1. javax.ws.rs.container.ContainerResponseFilter
  2. or
  3. javax.ws.rs.container.ContainerRequestFilter

After the REST server is started, if you use the raw SOFARPC, you need to register and then start the service. In a SOFABoot environment, the process is similar. Here is the sample code:

  1. com.alipay.sofa.rpc.server.rest.TraceRequestFilter
  2. com.alipay.sofa.rpc.server.rest.TraceResponseFilter