http

package
v2.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 24 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ApplicationProtoJsonContentType = "application/protojson"

	AcceptHeaderKey             = "Accept"
	AuthorizationHeaderKey      = "Authorization"
	ConnectionHeaderKey         = "Connection"
	ContentLengthHeaderKey      = "Content-Length"
	ContentTypeHeaderKey        = "Content-Type"
	ContentTypeOptionsHeaderKey = "X-Content-Type-Options"
	CorrelationIDHeaderKey      = "Correlation-Id"
	ETagHeaderKey               = "ETag"

	AuthorizationBearerPrefix = "Bearer "
)
View Source
const (
	AnyPathSuffixRegex = `\/.*`
)

Variables

This section is empty.

Functions

func CreateAuthMiddleware

func CreateAuthMiddleware(authInterceptor pkgHttpJwt.Interceptor, onUnauthorizedAccessFunc OnUnauthorizedAccessFunc) func(next http.Handler) http.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(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 GetToken added in v2.23.0

func GetToken(auth string) (string, error)

func NewDefaultAuthorizationRules added in v2.13.0

func NewDefaultAuthorizationRules(apiPath string) map[string][]pkgHttpJwt.AuthArgs

NewDefaultAuthorizationRules returns a map of HTTP methods to a slice of AuthArgs. The AuthArgs contain a URI field that is a regular expression matching the given apiPath with any path suffix. This function is used to create default authorization rules for HTTP methods GET, POST, DELETE, and PUT.

func OpenTelemetryNewHandler added in v2.4.0

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

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 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 http.ResponseWriter, r *http.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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