middleware

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CORS

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

CORS struct is just middleware that can be used to set access control This object containe 4 field. The field that held by this struct is : --> middleware : middleware field is data with type of *UseMiddleware --> allowOrigin : this field will held all origin that can be set into CORS.

the allowOrigin is field with []string data type

--> allowMethod : this field will held all method that can be set into CORS.

the allowMethod is field with []string data type

--> allowHeader : this field will held all header that can be set into CORS.

the allowHeader is field with []string data type

func NewCORS

func NewCORS() *CORS

NewCORS function will return *CORS

func (*CORS) AddHandler

func (cors *CORS) AddHandler(handler http.Handler)

Function AddHandler will add http.Handler into the CORS Before the request into the handler, the reqeust will be handler by this CORS

func (*CORS) AllowHeaders

func (cors *CORS) AllowHeaders(headers ...string)

AllowOrigins function is used to set all allowed headers

func (*CORS) AllowMethods

func (cors *CORS) AllowMethods(methods ...string)

AllowOrigins function is used to set all allowed methods

func (*CORS) AllowOrigins

func (cors *CORS) AllowOrigins(origins ...string)

AllowOrigins function is used to set all allowed origin

func (*CORS) ServeHTTP

func (cors *CORS) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Middleware

type Middleware func(next http.Handler) http.Handler

Middleware is a function that need one parameter with type of http.Handler and will return a http.Handler

type UseJWTMiddlewarewithECDSA added in v0.1.4

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

func NewJWTMiddlewarewithECDSA added in v0.1.4

func NewJWTMiddlewarewithECDSA(privateKey string) *UseJWTMiddlewarewithECDSA

func (*UseJWTMiddlewarewithECDSA) AddHandler added in v0.1.4

func (ec *UseJWTMiddlewarewithECDSA) AddHandler(handler http.Handler)

func (*UseJWTMiddlewarewithECDSA) ServeHTTP added in v0.1.4

type UseMiddleware

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

UseMiddleware struct can create an object to apply UseMiddleware in specific *multiplexer.Router object. This struct has two field. The first field is : ---> function, which is a Middleware Function The second one is : --> handler, which is a http.Handler where the middleware will be applied

func NewUseMiddleware

func NewUseMiddleware() *UseMiddleware

NewUseMiddleware will return UseMiddleware object

func (*UseMiddleware) AddHandler

func (um *UseMiddleware) AddHandler(handler http.Handler)

AddRouter function will add new http.Handler into the UseMiddleware object

func (*UseMiddleware) AddMiddleware

func (um *UseMiddleware) AddMiddleware(middleware Middleware)

AddMiddleware function will add new Middleware function into the UseMiddleware object

func (*UseMiddleware) ServeHTTP

func (mw *UseMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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