Documentation
¶
Index ¶
- Constants
- type CheckOptions
- type OpenAPI
- func (oapi OpenAPI) CaddyModule() caddy.ModuleInfo
- func (oapi *OpenAPI) Provision(ctx caddy.Context) error
- func (oapi OpenAPI) ServeHTTP(w http.ResponseWriter, req *http.Request, next caddyhttp.Handler) error
- func (oapi *OpenAPI) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- func (oapi OpenAPI) Validate() error
- type WrapperResponseWriter
Constants ¶
View Source
const ( MODULE_ID = "http.handlers.openapi" X_POLICY = "x-policy" OPENAPI_ERROR = "openapi.error" OPENAPI_STATUS_CODE = "openapi.status_code" OPENAPI_RESPONSE_ERROR = "openapi.response_error" TOKEN_OPENAPI = "openapi" TOKEN_POLICY_BUNDLE = "policy_bundle" TOKEN_SPEC = "spec" TOKEN_FALL_THROUGH = "fall_through" TOKEN_LOG_ERROR = "log_error" TOKEN_VALIDATE_SERVERS = "validate_servers" TOKEN_CHECK = "check" VALUE_REQ_PARAMS = "req_params" VALUE_REQ_BODY = "req_body" VALUE_RESP_BODY = "resp_body" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckOptions ¶
type CheckOptions struct {
// Enable request query validation. Default is `false`
RequestParams bool `json:"req_params,omitempty"`
// Enable request payload validation. Default is `false`
RequestBody bool `json:"req_body,omitempty"`
// Enable response body validation with an optional list of
// `Content-Type` to examine. Default `application/json`. If you set
// your content type, the default will be removed
ResponseBody []string `json:"resp_body,omitempty"`
}
type OpenAPI ¶
type OpenAPI struct {
// The location of the OASv3 file
Spec string `json:"spec"`
PolicyBundle string `json:"policy_bundle"`
// Should the request proceed if it fails validation. Default is `false`
FallThrough bool `json:"fall_through,omitempty"`
// Should the non compliant request be logged? Default is `false`
LogError bool `json:"log_error,omitempty"`
// Enable request and response validation
Check *CheckOptions `json:"check,omitempty"`
// Enable server validation
ValidateServers bool `json:"valid_servers,omitempty"`
// contains filtered or unexported fields
}
This middleware validates request against an OpenAPI V3 specification. No conforming request can be rejected
func (OpenAPI) CaddyModule ¶
func (oapi OpenAPI) CaddyModule() caddy.ModuleInfo
func (*OpenAPI) UnmarshalCaddyfile ¶
type WrapperResponseWriter ¶
type WrapperResponseWriter struct {
http.ResponseWriter
StatusCode int
Buffer []byte
}
func (*WrapperResponseWriter) Write ¶
func (w *WrapperResponseWriter) Write(buff []byte) (int, error)
func (*WrapperResponseWriter) WriteHeader ¶
func (w *WrapperResponseWriter) WriteHeader(sc int)
Click to show internal directories.
Click to hide internal directories.