accesscontrol

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrResrouceMissing 未提供资源
	ErrResrouceMissing = errors.New("required resource not found")
)

Functions

func OnError

func OnError(ctx context.Context, err error)

OnError is the default error handler. Use it to change the behavior for each error. See `Config.ErrorHandler`.

Types

type Config

type Config struct {
	// 资源
	ResourceValue string
	// The function that will be called when there's an error validating the token
	// Default value:
	ErrorHandler errorHandler
}

Config is

type Middleware

type Middleware struct {
	Config Config
}

Middleware the middleware for JSON Web tokens authentication method

func New

func New(resource string) *Middleware

New constructs a new Secure instance with supplied options.

func (*Middleware) CheckAccessControl

func (m *Middleware) CheckAccessControl(ctx context.Context) error

CheckAccessControl the main functionality, checks for token

func (*Middleware) Serve

func (m *Middleware) Serve(ctx context.Context)

Serve the middleware's action

Jump to

Keyboard shortcuts

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