chiwares

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: Apache-2.0 Imports: 7 Imported by: 2

README

go-chi-middlewares

Common middlewares used in projects with go-chi. Just import necessary middlewares without reimplementation of them each time in a new project.

Getting started

Add go-chi-middlewares as a dependency to your project

go get github.com/anfimovoleh/go-chi-middlewares

The code above fetches the go-chi-middlewares as your project dependency.

Current list of middlewares

  • Logger(zap);
  • Basic Auth;
  • Context(set objects to http request context);
  • Verify remote address is private.

We are planning to add next middlewares in the near future:

  • JWT Auth;
  • OAuth2
  • Rate limiter;

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BasicAuth

func BasicAuth(username, password string) func(http.Handler) http.Handler

BasicAuth verifies provided in header username and password

func Ctx added in v1.1.0

func Ctx(extenders ...func(context.Context) context.Context) func(http.Handler) http.Handler

func Logger

func Logger(logger *zap.Logger, durationThreshold time.Duration) func(http.Handler) http.Handler

func PrivateAddressPool

func PrivateAddressPool() []net.IPNet

func VerifyRemoteAddressIsPrivate

func VerifyRemoteAddressIsPrivate(privateAddressPool []net.IPNet) func(http.Handler) http.Handler

VerifyRemoteAddressIsPrivate verifies origin client IP contains in privateAddressPool if len(privateAddressPool) == 0, than system uses default pool from PrivateAddressPool you can set or add additional IP addresses to the IP-pool.

Types

This section is empty.

Jump to

Keyboard shortcuts

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