middleware

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package middleware provides settings for CORS, GZIP and JWT token validation.

CORS sets the accepted headers, permitted sources and methods accepted by the request:

h := middleware.CORS(h)
// ...

GZIP compress the http responses:

h := middleware.GZIP(h)
// ...

Auth validates HTTP requests via token JWT:

var jwt auth.JWT
// ...

auth := middleware.NewAuth(jwt)
auth.RequireTokenAuth(w, r, next)
// ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(h http.Handler) http.Handler

CORS sets the accepted headers, permitted sources and methods accepted by the request.

func GZIP

func GZIP(h http.Handler) http.Handler

GZIP compress the http responses.

Types

type Auth

type Auth interface {
	RequireTokenAuth(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
}

Auth validates HTTP requests via token.

func NewAuth

func NewAuth(jwt auth.JWT) Auth

NewAuth creates a new instance of Auth and receives an jwt.JWT object as a parameter.

Jump to

Keyboard shortcuts

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