用户工具

站点工具


light4j:example
git clone https://github.com/networknt/light-example-4j
  • middleware-performance,提供三种配置方式:1单独配置,2OpenApiEndpointSource,3PathHandlerProvider;综合来看第2种最方便
# 公共配置
  - com.networknt.exception.ExceptionHandler@exception
  - com.networknt.metrics.MetricsHandler@metrics
  - com.networknt.traceability.TraceabilityHandler@traceability
  - com.networknt.correlation.CorrelationHandler@correlation
  - com.networknt.openapi.OpenApiHandler@specification
  - com.networknt.openapi.JwtVerifyHandler@security
  - com.networknt.body.BodyHandler@body
  - com.networknt.audit.AuditHandler@audit
  - com.networknt.sanitizer.SanitizerHandler@sanitizer
  - com.networknt.openapi.ValidatorHandler@validator
# 1,单独配置
- com.networknt.petstore.handler.PetsGetHandler
paths:
  - path: '/v1/pets'
    method: 'get'
    exec:
      - default
      - com.networknt.petstore.handler.PetsGetHandler
# 2,endpoint source,light-codegen可以自动生成OpenApiPathHandler,判断audit_info.endpoint分别调用new PetsGetHandler().handleRequest
  - com.networknt.petstore.handler.OpenApiPathHandler@openapi-handler
paths:
  - source: com.networknt.openapi.OpenApiEndpointSource
    exec: 
      - default
      - openapi-handler
# 3,PathHandlerProvider,service.yml,Handlers.routing().add(Methods.GET, "/v1/health", new HealthGetHandler())
- com.networknt.handler.HandlerProvider:
  - com.networknt.petstore.PathHandlerProvider
light4j/example.txt · 最后更改: 2021/11/26 18:45 由 admin