middleware

package
v1.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeStats

CodesStats is a middleware that captures the status code and method of the request for metrics collection with Prometheus

func CustomValidator

func CustomValidator(h http.Handler, customValidator ValidationFunc, url opa.OPAURL, pkg string) http.Handler

CustomValidtor allows for calling a specific OPA instance and defining the package name For example, to call a sidecar instead of the central OPA server and to only call the cw/underwriting package instead of the full cw package.

func GraphQLCustomValidator

func GraphQLCustomValidator(handler http.Handler, customValidator ValidationFunc, url opa.OPAURL, pkg string) http.Handler

GraphQLCustomValidator is like the other CustomValidator function but for GraphQL requests. It passes through data if the query type is an introspection so that schema requests aren't validated by OPA

func Logging

func Logging(h http.Handler) http.Handler

func RequestID

func RequestID(h http.Handler) http.Handler

func StandardValidator

func StandardValidator(h http.Handler) http.Handler

StandardValidator calls the central OPA server with the full cw validation pacakge

Types

type Query

type Query struct {
	OperationName string    `json:"operationName,omitempty"`
	Variables     Variables `json:"variables"`
}

type StatusRec added in v0.2.0

type StatusRec struct {
	http.ResponseWriter
	Status int
}

StatusRec wraps the http.ResponseWriter to capture the status code

func (*StatusRec) WriteHeader added in v0.2.0

func (r *StatusRec) WriteHeader(status int)

WriteHeader captures the status code

type ValidationFunc

type ValidationFunc func([]byte) (opa.OPARequest, error)

ValidationFunc is used to map the data in the incoming request to an OPA request. It's on the caller of the service to define the data in the OPA request and what package is called in OPA.

type Variables

type Variables struct {
	Data any `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL