httprouter

package
v1.0.37 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2021 License: Apache-2.0 Imports: 16 Imported by: 10 modules, 32 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON           = "application/json"
	ContentTypeText           = "text/plain"
	ContentTypeMultipartForm  = "multipart/form-data"
	ContentTypeUrlEncodedForm = "application/x-www-form-urlencoded"
)
View Source
const (
	PathSeparator = string(os.PathSeparator)
)

Variables

This section is empty.

Functions

func New added in v1.0.15

func New() *router

func RequestBody added in v1.0.15

func RequestBody(req *http.Request, v interface{}) error

RequestBody returns the body of a request as a struct

func RequestBodyForm added in v1.0.15

func RequestBodyForm(req *http.Request, params map[string]string, v interface{}) error

RequestBodyForm returns the body of a request as a struct where the request is of type multipart/form-data

func RequestBodyJSON added in v1.0.15

func RequestBodyJSON(req *http.Request, v interface{}) error

RequestBodyJSON returns the body of a request as a struct where the request is of type application/json

func RequestBodyPost added in v1.0.15

func RequestBodyPost(req *http.Request, v interface{}) error

RequestBodyPost returns the body of a request as a struct where the request is of type application/x-www-form-urlencoded

func RequestParams added in v1.0.15

func RequestParams(req *http.Request) []string

RequestParams returns the parameters encoded within the reqular expression

func RequestQuery added in v1.0.15

func RequestQuery(req *http.Request, v interface{}) error

RequestQuery returns the query string of a request as a struct

func ServeError added in v1.0.15

func ServeError(w http.ResponseWriter, code int, reason ...string) error

ServeError is a utility function to serve a JSON error notice

func ServeJSON added in v1.0.15

func ServeJSON(w http.ResponseWriter, v interface{}, code, indent uint) error

ServeJSON is a utility function to serve an arbitary object as JSON

func ServeText added in v1.0.15

func ServeText(w http.ResponseWriter, v string, code int)

ServeText is a utility function to serve plaintext

Types

type ErrorResponse added in v1.0.15

type ErrorResponse struct {
	Code   int    `json:"code"`
	Reason string `json:"reason,omitempty"`
}

Jump to

Keyboard shortcuts

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