interceptor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AUTHORIZATION               string = "Authorization"
	HEADER_USER_NAME            string = "User-Name"
	HEADER_CUSTOMER_ID          string = "Customer-Id"
	HEADER_USER_ID              string = "User-Id"
	HEADER_SERVICE_ID           string = "Service-Id"
	HEADER_INPUT_APP            string = "x-application-vkn"
	HEADER_APP_ID               string = "App-Id"
	HEADER_REMOTE_IP            string = "Remote-Ip"
	HEADER_REQUEST_WEIGHT_NAME  string = "x-application-rw"
	HEADER_REQUEST_WEIGHT_VALUE string = "x-application-rv"
	HEADER_TIMESTAMP            string = "x-application-alo"
	HEADER_PLAN_ID              string = "Plan-Id"
	HEADER_PLAN_IPFS_STORAGE    string = "Plan-Storage"
	HEADER_IPFS_STORAGE         string = "Ipfs-Storage"
	HEADER_JTI                  string = "jti"
)
View Source
const (
	INSUFFICIENT_SCOPE_ERROR       string = "INSUFFICIENT_SCOPE_ERROR"
	USER_AGENT_CHANGED             string = "USER_AGENT_CHANGE"
	INVALID_TOKEN_ERROR            string = "INVALID_TOKEN_ERROR"
	INVALID_APP_ID                 string = "INVALID_APP_ID"
	INVALID_CUSTOMER_ID            string = "INVALID_CUSTOMER_ID"
	PARAM_NETWORK_ID               string = "network"
	PARAM_OFFSET                   string = "o"
	PARAM_MAX_ROWS                 string = "n"
	CORE_VIEW_WEIGHT_NAME_DEFAULT  string = "CORE_VIEW"
	CORE_VIEW_WEIGHT_VALUE_DEFAULT string = "1"
)

Variables

This section is empty.

Functions

func LaunchMemStats

func LaunchMemStats()

func NewElapsedTimeInterceptor

func NewElapsedTimeInterceptor() mux.MiddlewareFunc

Intercepts the request and calculates the total run time from start to finish

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer is an interceptor that recovers from panics, logs the panic (and the stacktrace), and returns a HTTP 500 (Internal Server Error) status if possible.

Types

type ErrorDTO

type ErrorDTO struct {
	// The error code
	// in: string
	Code string `json:"code"`
	// The error message
	// in: string
	Message string `json:"message"`
}

func NewErrorDTO

func NewErrorDTO(code, message string) ErrorDTO

NewErrorDTO returns a new ErrorDTO

type MiddlewareChain

type MiddlewareChain []MiddlewareInterceptor

MiddlewareChain is a collection of interceptors that will be invoked in there index order

func (MiddlewareChain) Handler

func (chain MiddlewareChain) Handler(handler http.HandlerFunc) http.Handler

Handler allows hooking multiple middleware in single call.

type MiddlewareHandlerFunc

type MiddlewareHandlerFunc http.HandlerFunc

MiddlewareHandlerFunc builds on top of http.HandlerFunc, and exposes API to intercept with MiddlewareInterceptor. This allows building complex long chains without complicated struct manipulation

func (MiddlewareHandlerFunc) Intercept

Intercept returns back a continuation that will call install middleware to intercept the continuation call.

type MiddlewareInterceptor

type MiddlewareInterceptor func(http.ResponseWriter, *http.Request, http.HandlerFunc)

MiddlewareInterceptor intercepts an HTTP handler invocation, it is passed both response writer and request which after interception can be passed onto the handler function.

func TimestampHeaderInterceptor

func TimestampHeaderInterceptor() MiddlewareInterceptor

type RoleValidator

type RoleValidator func(request *http.Request, customerInfo *jwt.CustomerInfo) bool

Interface used to execute SecurityTokenInterceptor url filtering for authorization

type ServiceConfig

type ServiceConfig struct {
	ServiceID   uint64
	Environment uint8
}

ServiceConfig contains the ServiceID and Environment values of the application that uses Middleware to secure access to endpoints.

func (*ServiceConfig) JwtInterceptor

func (config *ServiceConfig) JwtInterceptor(roleValidator RoleValidator, dbTokenValidator jwt.DBTokenValidator) MiddlewareInterceptor

JwtInterceptor Executes all operations necessary to validate that the token received contains the credentials required for the request. Receives as parameter RoleValidator from the applica

Jump to

Keyboard shortcuts

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