mw

package
v0.2.2-rc7 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsHandlerFunc

func AsHandlerFunc(a Action) http.HandlerFunc

AsHandlerFunc is a helper wrapper to make implementing actions easier

func Database

func Database(r *http.Request) *mongo.Database

Database gets the database configured on the request

Types

type Action

type Action func(r *http.Request) (interface{}, Response)

Action interface

type AuthMiddleware

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

AuthMiddleware implements https://tools.ietf.org/html/draft-cavage-http-signatures-12 authentication scheme as an HTTP middleware

func NewAuthMiddleware

func NewAuthMiddleware(v *httpsig.Verifier) *AuthMiddleware

NewAuthMiddleware creates a new AuthMiddleware using the v httpsig.Verifier

func (*AuthMiddleware) Middleware

func (a *AuthMiddleware) Middleware(handler http.Handler) http.Handler

Middleware implements mux.Middlware interface

type DatabaseMiddleware

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

DatabaseMiddleware middleware

func NewDatabaseMiddleware

func NewDatabaseMiddleware(dbName string, client *mongo.Client) (*DatabaseMiddleware, error)

NewDatabaseMiddleware creates a new database middleware

func (*DatabaseMiddleware) Database

func (d *DatabaseMiddleware) Database() *mongo.Database

Database return database as configured in the middleware

func (*DatabaseMiddleware) Middleware

func (d *DatabaseMiddleware) Middleware(next http.Handler) http.Handler

Middleware is the middleware function

type NodeKeyGetter

type NodeKeyGetter struct{}

NodeKeyGetter implements httpsig.KeyGetter for the nodes collections

func NewNodeKeyGetter

func NewNodeKeyGetter() NodeKeyGetter

NewNodeKeyGetter create a httpsig.KeyGetter that uses the nodes collection to find the key

func (NodeKeyGetter) GetKey

func (m NodeKeyGetter) GetKey(id string) interface{}

GetKey implements httpsig.KeyGetter

type Response

type Response interface {
	Status() int
	Err() error

	// header getter
	Header() http.Header
	// header setter
	WithHeader(k, v string) Response
}

Response interface

func BadRequest

func BadRequest(err error) Response

BadRequest result

func Conflict

func Conflict(err error) Response

Conflict response

func Created

func Created() Response

Created return a created response

func Error

func Error(err error, code ...int) Response

Error generic error response

func Forbidden

func Forbidden(err error) Response

Forbidden response

func NoContent

func NoContent() Response

NoContent response

func NotFound

func NotFound(err error) Response

NotFound response

func Ok

func Ok() Response

Ok return a ok response

func UnAuthorized

func UnAuthorized(err error) Response

UnAuthorized response

type UserKeyGetter

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

UserKeyGetter implements httpsig.KeyGetter for the users collections

func NewUserKeyGetter

func NewUserKeyGetter(db *mongo.Database) UserKeyGetter

NewUserKeyGetter create a httpsig.KeyGetter that uses the users collection to find the key

func (UserKeyGetter) GetKey

func (u UserKeyGetter) GetKey(id string) interface{}

GetKey implements httpsig.KeyGetter

Jump to

Keyboard shortcuts

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