APIMode

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIFWModeAPI

type APIFWModeAPI struct {
	// contains filtered or unexported fields
}

func (*APIFWModeAPI) GetPrometheusCollectors added in v0.9.2

func (a *APIFWModeAPI) GetPrometheusCollectors() ([]prometheus.Collector, error)

GetPrometheusCollectors returns Prometheus collectors for external registration and monitoring

func (*APIFWModeAPI) UpdateSpecsStorage

func (a *APIFWModeAPI) UpdateSpecsStorage() ([]int, bool, error)

UpdateSpecsStorage method reloads data from SQLite DB with specs

func (*APIFWModeAPI) ValidateRequest

func (a *APIFWModeAPI) ValidateRequest(schemaIDs []int, uri, method, body []byte, headers map[string][]string) (*validator.ValidationResponse, error)

ValidateRequest method validates request against the spec with provided schema ID

func (*APIFWModeAPI) ValidateRequestFromReader

func (a *APIFWModeAPI) ValidateRequestFromReader(schemaIDs []int, r *bufio.Reader) (*validator.ValidationResponse, error)

ValidateRequestFromReader method validates request against the spec with provided schema ID

type APIFirewall

type APIFirewall interface {
	ValidateRequestFromReader(schemaIDs []int, r *bufio.Reader) (*validator.ValidationResponse, error)
	ValidateRequest(schemaIDs []int, uri, method, body []byte, headers map[string][]string) (*validator.ValidationResponse, error)
	UpdateSpecsStorage() ([]int, bool, error)
	GetPrometheusCollectors() ([]prometheus.Collector, error)
}

func NewAPIFirewall

func NewAPIFirewall(options ...Option) (APIFirewall, error)

type Configuration

type Configuration struct {
	PathToSpecDB               string
	DBVersion                  int
	UnknownParametersDetection bool
	PassOptionsRequests        bool
	MaxErrorsInResponse        int
	MetricsEnabled             bool
}

type Option

type Option func(*Configuration)

func DisablePassOptionsRequests

func DisablePassOptionsRequests() Option

DisablePassOptionsRequests is a functional option to disable requests with method OPTIONS

func DisableUnknownParameters

func DisableUnknownParameters() Option

DisableUnknownParameters is a functional option to disable following redirects.

func EnablePassOptionsRequests added in v0.9.2

func EnablePassOptionsRequests() Option

EnablePassOptionsRequests is a functional option to enable requests with method OPTIONS

func EnablePrometheusMetrics added in v0.9.2

func EnablePrometheusMetrics() Option

EnablePrometheusMetrics is a functional option to enable prometheus metrics

func WithDBVersion

func WithDBVersion(dbVersion int) Option

WithDBVersion is a functional option to set the SQLLite DB structure version

func WithMaxErrorsInResponse added in v0.9.1

func WithMaxErrorsInResponse(limit int) Option

WithMaxErrorsInResponse is a functional option to set max errors in the response

func WithPathToDB

func WithPathToDB(path string) Option

WithPathToDB is a functional option to set path to the SQLLite DB with the OpenAPI specifications

type RequestValidator

type RequestValidator struct {
	CustomRoute   *loader.CustomRoute
	OpenAPIRouter *loader.Router
	ParserPool    *fastjson.ParserPool
	Metrics       metrics.Metrics
	SchemaID      int
	Options       *Configuration
}

func (*RequestValidator) APIModeHandler

func (rv *RequestValidator) APIModeHandler(ctx *fasthttp.RequestCtx) (err error)

APIModeHandler finds route in the OpenAPI spec and validates request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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