resource

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultResourceChecker

func DefaultResourceChecker(ctx context.Context) (context.Context, error)

check request is a exact match (leaf, not intermediate router) and makes sure there is no trailing slash

Types

type Checker

type Checker interface {
	Check(ctx context.Context) (context.Context, error)
}

type ContextChecker

type ContextChecker func(ctx context.Context) (context.Context, error)

type Deleter

type Deleter interface {
	Delete(rw http.ResponseWriter, req *http.Request) error
}

DELETE

type Getter

type Getter interface {
	Get(rw http.ResponseWriter, req *http.Request) error
}

GET

type Optioner

type Optioner interface {
	Options(rw http.ResponseWriter, req *http.Request) error
}

OPTIONS

type Peeker

type Peeker interface {
	Head(rw http.ResponseWriter, req *http.Request) error
}

HEAD

type Poster

type Poster interface {
	Post(rw http.ResponseWriter, req *http.Request) error
}

POST

type Resource

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

func NewResource

func NewResource(v interface{}, eh web.ErrorHandlerFunc, check ContextChecker) *Resource

func (Resource) BadRequest

func (_ Resource) BadRequest(err error) *errors.BadRequestError

func (Resource) BadRequestf

func (_ Resource) BadRequestf(s string, args ...interface{}) *errors.BadRequestError

func (Resource) BestMime

func (_ Resource) BestMime(req *http.Request, supported ...string) (string, error)

func (Resource) FormValue

func (_ Resource) FormValue(req *http.Request, key string) (string, error, bool)

Tries to get a string field from a POSTed form

func (Resource) FormValueBool

func (_ Resource) FormValueBool(req *http.Request, key string) (bool, error, bool)

Tries to get a bool field from a POSTed form

func (Resource) FormValueFloat32

func (_ Resource) FormValueFloat32(req *http.Request, key string) (float32, error, bool)

Tries to get a float32 field from a POSTed form

func (Resource) FormValueInt16

func (_ Resource) FormValueInt16(req *http.Request, key string) (int16, error, bool)

Tries to get a int16 field from a POSTed form

func (Resource) FormValueInt32

func (_ Resource) FormValueInt32(req *http.Request, key string) (int32, error, bool)

Tries to get a int32 field from a POSTed form

func (*Resource) Init

func (m *Resource) Init(v interface{}, eh web.ErrorHandlerFunc, check ContextChecker)

func (Resource) ParseForm

func (_ Resource) ParseForm(req *http.Request, size int64) error

func (Resource) RouteParam

func (_ Resource) RouteParam(req *http.Request, key string) (interface{}, error, bool)

Tries to get a interface{} Route Parameter from RouteContext

func (Resource) RouteParamInt

func (_ Resource) RouteParamInt(req *http.Request, key string) (int, error, bool)

Tries to get a int Route Parameter from RouteContext

func (Resource) RouteParamIntSlice

func (_ Resource) RouteParamIntSlice(req *http.Request, key string) ([]int, error, bool)

Tries to get slice of int Route Parameters from RouteContext

func (Resource) RouteParamSlice

func (_ Resource) RouteParamSlice(req *http.Request, key string) ([]interface{}, error, bool)

Tries to get slice of interface{} Route Parameters from RouteContext

func (Resource) RouteParamString

func (_ Resource) RouteParamString(req *http.Request, key string) (string, error, bool)

Tries to get a string Route Parameter from RouteContext

func (Resource) RouteParamStringSlice

func (_ Resource) RouteParamStringSlice(req *http.Request, key string) ([]string, error, bool)

Tries to get slice of string Route Parameters from RouteContext

func (Resource) RoutePath

func (_ Resource) RoutePath(req *http.Request) string

func (Resource) SeeOther

func (_ Resource) SeeOther(location string, args ...interface{}) *errors.RedirectError

func (*Resource) ServeHTTP

func (m *Resource) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*Resource) TryServeHTTP

func (m *Resource) TryServeHTTP(rw http.ResponseWriter, req *http.Request) error

func (Resource) WriteJSON

func (_ Resource) WriteJSON(w http.ResponseWriter, prefix string, indent string, d interface{}) error

Jump to

Keyboard shortcuts

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