Documentation ¶
Index ¶
- Constants
- func CanonicalHref(href string) string
- func CreateAuthMiddleware(authInterceptor Interceptor, onUnauthorizedAccessFunc OnUnauthorizedAccessFunc) func(next http.Handler) http.Handler
- func CreateLoggingMiddleware(opts ...LogOpt) func(next http.Handler) http.Handler
- func CreateMakeQueryCaseInsensitiveMiddleware(queryCaseInsensitive map[string]string, opts ...LogOpt) func(next http.Handler) http.Handler
- func CreateTrailSlashSuffixMiddleware(opts ...LogOpt) func(next http.Handler) http.Handler
- func DefaultCodeToLevel(code int, logger log.Logger) func(args ...interface{})
- func ErrToStatus(err error) int
- func ErrToStatusWithDef(err error, def int) int
- func NewDefaultAuthorizationRules(apiPath string) map[string][]AuthArgs
- func OpenTelemetryNewHandler(handler http.Handler, serviceName string, tracerProvider trace.TracerProvider) http.Handler
- func ParseToken(auth string) (string, error)
- func ToURLString(scheme string, host string, path string) string
- func WantToLog(code int, logger log.Logger) bool
- type AuthArgs
- type ClaimsFunc
- type DeniedClaims
- type Interceptor
- type LogOpt
- type LogOptions
- type OnUnauthorizedAccessFunc
- type OpenTelemetryCollectorConfig
- type RequestMatcher
- type Validator
Constants ¶
const ( ApplicationProtoJsonContentType = "application/protojson" CorrelationIDHeaderKey = "Correlation-Id" ContentLengthHeaderKey = "Content-Length" ContentTypeHeaderKey = "Content-Type" ContentTypeOptionsHeaderKey = "X-Content-Type-Options" AcceptHeaderKey = "Accept" ETagHeaderKey = "ETag" )
const (
AnyPathSuffixRegex = `\/.*`
)
Variables ¶
This section is empty.
Functions ¶
func CreateAuthMiddleware ¶
func CreateAuthMiddleware(authInterceptor Interceptor, onUnauthorizedAccessFunc OnUnauthorizedAccessFunc) func(next http.Handler) http.Handler
CreateAuthMiddleware creates middleware for authorization
func CreateLoggingMiddleware ¶ added in v2.2.4
func CreateMakeQueryCaseInsensitiveMiddleware ¶ added in v2.3.6
func CreateTrailSlashSuffixMiddleware ¶ added in v2.3.6
func DefaultCodeToLevel ¶ added in v2.2.4
DefaultCodeToLevel is the default implementation of gRPC return codes and interceptor log level for server side.
func ErrToStatusWithDef ¶
ErrToStatusWithDef converts err with default http.Status(for unknown conversion) to http.Status.
func NewDefaultAuthorizationRules ¶ added in v2.13.0
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 ParseToken ¶
func ToURLString ¶
ToURLString convert scheme, host, path to escaped url.
Types ¶
type ClaimsFunc ¶
func MakeClaimsFunc ¶
func MakeClaimsFunc(methods map[string][]AuthArgs) ClaimsFunc
type DeniedClaims ¶
type DeniedClaims struct { jwt.MapClaims Err error }
func (DeniedClaims) Validate ¶ added in v2.16.3
func (c DeniedClaims) Validate() error
type Interceptor ¶
func NewInterceptorWithValidator ¶
func NewInterceptorWithValidator(validator Validator, auths map[string][]AuthArgs, whiteList ...RequestMatcher) Interceptor
NewInterceptor authorizes HTTP request with validator.
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 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 ¶
RequestMatcher allows request without token validation.