simpleapi

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized         = errors.New("unauthorized")
	ErrBadRequest           = errors.New("bad request")
	ErrUnsupportedMediaType = errors.New("unsupported media type")
)

Functions

func BearerAuth

func BearerAuth(req *http.Request) (accessToken string, ok bool)

func Created

func Created(w http.ResponseWriter, resp interface{}) error

func ErrorStatusCode

func ErrorStatusCode(err error) (statusCode int)

func Handler

func Handler(handler RequestHandler) http.Handler

Types

type BookRequest

type BookRequest struct {
	Title   string   `json:"title"`
	ISBN    string   `json:"isbn"`
	Authors []string `json:"authors"`
}

func NewBookRequest

func NewBookRequest(req *http.Request) (*BookRequest, error)

func (*BookRequest) IsValid

func (req *BookRequest) IsValid() (ok bool)

type BooksHandler

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

func (*BooksHandler) Post

type RequestHandler

type RequestHandler func(w http.ResponseWriter, req *http.Request) error

Jump to

Keyboard shortcuts

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