SOFAStack provides the JAXRSProviderManager class for REST, which you can use to create custom filters.
The JAXRSProviderManager class runs on the server-side and takes effect at service startup. The interface is as follows:
com.alipay.sofa.rpc.server.rest.RestServer#registerProviderAfter initialization, call the following method to register your custom filter.
com.alipay.sofa.rpc.config.JAXRSProviderManager#registerCustomProviderInstanceA custom filter must follow REST specifications and implement one of the following interfaces:
javax.ws.rs.container.ContainerResponseFilter
or
javax.ws.rs.container.ContainerRequestFilterAfter the REST server starts, you must first register and then start the service for bare SOFARPC. The process is similar when using a SOFABoot environment. For a specific implementation, see the following example:
com.alipay.sofa.rpc.server.rest.TraceRequestFilter
com.alipay.sofa.rpc.server.rest.TraceResponseFilter该文章对您有帮助吗?