middleware

package
v0.0.0-...-68e8b16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package middleware contains HTTP middleware utilities

Index

Constants

This section is empty.

Variables

View Source
var WideOpen = CorsOptions{
	Origin:           "*",
	Methods:          []string{"POST", "GET", "OPTIONS", "PUT", "UPDATE", "DELETE"},
	Headers:          []string{"Accept", "Content-Type", "Content-Length", "Accept-Encoding", "Authorization"},
	ExposeHeaders:    []string{"*"},
	AllowCredentials: true,
}

WideOpen is a preset configuration allowing unrestricted CORS access

Functions

This section is empty.

Types

type CorsMiddleware

type CorsMiddleware struct {
	Options CorsOptions
}

func (CorsMiddleware) BeforeNext

func (cmw CorsMiddleware) BeforeNext(next http.Handler) http.Handler

type CorsOptions

type CorsOptions struct {
	Origin           string   // Origin specifies the origin that is allowed to access the resource
	Methods          []string // Methods is a list of HTTP methods allowed when accessing the resource
	Headers          []string // Headers is a list of HTTP headers that can be used when making the actual request
	ExposeHeaders    []string // ExposeHeaders indicates which headers are safe to expose to the API of a CORS API specification
	AllowCredentials bool     // AllowCredentials indicates whether or not the response to the request can be exposed when the credentials flag is true
}

CorsOptions defines the structure for CORS configuration options

type JWTBearerMiddleware

type JWTBearerMiddleware struct {
	JWTService service.JsonWebTokenService
	Logger     logging.Logger
}

func (JWTBearerMiddleware) BeforeNext

func (jwtmw JWTBearerMiddleware) BeforeNext(next http.Handler) http.Handler

type Middleware

type Middleware interface {
	BeforeNext(next http.Handler) http.Handler
}

type RequestLoggerMiddleware

type RequestLoggerMiddleware struct {
	Logger logging.Logger
}

func (RequestLoggerMiddleware) BeforeNext

func (rmw RequestLoggerMiddleware) BeforeNext(next http.Handler) http.Handler

Jump to

Keyboard shortcuts

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