http

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultErrorHandler = ErrorEncoder
)
View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

func ErrorEncoder

func ErrorEncoder(_ context.Context, err error, w http.ResponseWriter)

Types

type Config

type Config struct {
	ErrorHandler func(ctx context.Context, err error, w http.ResponseWriter)
}

func DefaultConfig

func DefaultConfig() Config

type Context

type Context struct {
	context.Context

	ResponseWriter http.ResponseWriter
	Request        *http.Request
	// contains filtered or unexported fields
}

func (*Context) Clone

func (c *Context) Clone() *Context

func (*Context) JSON

func (c *Context) JSON(resp interface{}) error

func (*Context) Next

func (c *Context) Next() (err error)

Next runs the next handler func until out of range

func (*Context) StatusCode

func (c *Context) StatusCode(code int) *Context

type Handler

type Handler interface {
	http.Handler
}

func CombineHandlers

func CombineHandlers(cfg Config, h ...HandlerFunc) Handler

CombineHandlers returns a http Handler

type HandlerFunc

type HandlerFunc func(*Context) error

func BasicAuthor

func BasicAuthor(author func(username, password string) bool) HandlerFunc

type Server

type Server interface {
	http.Handler
	Use(middleware ...HandlerFunc)
	Handle(pattern string, handlers ...HandlerFunc)
}

func New

func New() Server

Jump to

Keyboard shortcuts

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