mw

package
v0.2.2-rc4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2020 License: Apache-2.0 Imports: 7 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 DatabaseMiddleware

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

DatabaseMiddleware middleware

func NewDatabaseMiddleware

func NewDatabaseMiddleware(name, url string) (*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 Response

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

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 NotFound

func NotFound(err error) Response

NotFound response

func UnAuthorized

func UnAuthorized(err error) Response

UnAuthorized response

Jump to

Keyboard shortcuts

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