http

package
v2.7.12 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanonicalHref

func CanonicalHref(href string) string

CanonicalHref always lead by "/"

func CreateAuthMiddleware

func CreateAuthMiddleware(authInterceptor Interceptor, onUnauthorizedAccessFunc OnUnauthorizedAccessFunc) func(next netHttp.Handler) netHttp.Handler

CreateAuthMiddleware creates middleware for authorization

func CreateLoggingMiddleware added in v2.2.4

func CreateLoggingMiddleware(opts ...LogOpt) func(next http.Handler) http.Handler

func CreateMakeQueryCaseInsensitiveMiddleware added in v2.3.6

func CreateMakeQueryCaseInsensitiveMiddleware(queryCaseInsensitive map[string]string, opts ...LogOpt) func(next http.Handler) http.Handler

func CreateTrailSlashSuffixMiddleware added in v2.3.6

func CreateTrailSlashSuffixMiddleware(queryCaseInsensitive map[string]string, opts ...LogOpt) func(next http.Handler) http.Handler

func DefaultCodeToLevel added in v2.2.4

func DefaultCodeToLevel(code int, logger log.Logger) func(args ...interface{})

DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.

func ErrToStatus

func ErrToStatus(err error) int

ErrToStatus converts err to http.Status.

func ErrToStatusWithDef

func ErrToStatusWithDef(err error, def int) int

ErrToStatusWithDef converts err with default http.Status(for unknown conversion) to http.Status.

func OpenTelemetryNewHandler added in v2.4.0

func OpenTelemetryNewHandler(handler http.Handler, serviceName string, tracerProvider trace.TracerProvider) http.Handler

func ParseToken

func ParseToken(auth string) (string, error)

func ToURLString

func ToURLString(scheme string, host string, path string) string

ToURLString convert scheme, host, path to escaped url.

func WantToLog added in v2.2.4

func WantToLog(code int, logger log.Logger) bool

DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.

Types

type AuthArgs

type AuthArgs struct {
	URI    *regexp.Regexp
	Scopes []*regexp.Regexp
}

type Claims

type Claims = interface{ Valid() error }

type ClaimsFunc

type ClaimsFunc = func(ctx context.Context, method, uri string) Claims

func MakeClaimsFunc

func MakeClaimsFunc(methods map[string][]AuthArgs) ClaimsFunc

type DeniedClaims

type DeniedClaims struct {
	Err error
}

func (DeniedClaims) Valid

func (c DeniedClaims) Valid() error

type Interceptor

type Interceptor = func(ctx context.Context, method, uri string) (context.Context, error)

func NewInterceptorWithValidator

func NewInterceptorWithValidator(validator Validator, auths map[string][]AuthArgs, whiteList ...RequestMatcher) Interceptor

NewInterceptor authorizes HTTP request with validator.

type LogOpt added in v2.2.4

type LogOpt = func(*LogOptions)

func WithLogger added in v2.2.4

func WithLogger(logger log.Logger) LogOpt

type LogOptions added in v2.3.6

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

func NewLogOptions added in v2.3.6

func NewLogOptions() *LogOptions

type OnUnauthorizedAccessFunc

type OnUnauthorizedAccessFunc = func(ctx context.Context, w netHttp.ResponseWriter, r *netHttp.Request, err error)

type OpenTelemetryCollectorConfig added in v2.4.0

type OpenTelemetryCollectorConfig struct {
	otelClient.Config `yaml:",inline"`
}

func (*OpenTelemetryCollectorConfig) Validate added in v2.4.0

func (c *OpenTelemetryCollectorConfig) Validate() error

type RequestMatcher

type RequestMatcher struct {
	Method string
	URI    *regexp.Regexp
}

RequestMatcher allows request without token validation.

type Validator

type Validator interface {
	ParseWithClaims(token string, claims extJwt.Claims) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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