Created
December 28, 2019 11:42
-
-
Save caoxudong/bb13233818729e49ec80373cbea6b851 to your computer and use it in GitHub Desktop.
intercept actuator uri in springboot 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package demo; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties; | |
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; | |
import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration; | |
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; | |
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier; | |
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointsSupplier; | |
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointsSupplier; | |
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
public class ActuatorConfig | |
extends WebMvcEndpointManagementContextConfiguration { | |
@Autowired | |
private MyInterceptor myInterceptor; | |
@Override | |
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping( | |
WebEndpointsSupplier webEndpointsSupplier, | |
ServletEndpointsSupplier servletEndpointsSupplier, | |
ControllerEndpointsSupplier controllerEndpointsSupplier, | |
EndpointMediaTypes endpointMediaTypes, | |
CorsEndpointProperties corsProperties, | |
WebEndpointProperties webEndpointProperties) { | |
WebMvcEndpointHandlerMapping mapping = | |
super.webEndpointServletHandlerMapping(webEndpointsSupplier, | |
servletEndpointsSupplier, controllerEndpointsSupplier, | |
endpointMediaTypes, corsProperties, | |
webEndpointProperties); | |
mapping.setInterceptors(myInterceptor); | |
return mapping; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment