hutil

package
v0.0.0-...-666e6c6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(body []byte, dbx *sqlx.DB) (model.User, error)

Authenticate confirms that the request is created by a registered user and identifies her/him.

func CORSMiddleware

func CORSMiddleware() func(*web.C, http.Handler) http.Handler

CORSMiddleware is a Goji middleware adding headers about Cross-Origin Resource Sharing.

func ReadWholeBody

func ReadWholeBody(httpReq *http.Request) ([]byte, error)

ReadWholeBody stores the entire request body into a byte array.

func RenderJSON

func RenderJSON(w http.ResponseWriter, data interface{})

RenderJSON stringifies `data` as JSON and writes it to the response.

func ReportError

func ReportError(w http.ResponseWriter, err error) bool

ReportError writes an JSON string containing the error message to the response.

func ReportOK

func ReportOK(w http.ResponseWriter)

ReportOK writes an nullary successful JSON string to the response.

func Wrap

func Wrap(
	dbx *sqlx.DB, raw func(web.C, http.ResponseWriter, *http.Request, *sqlx.DB, []byte, model.User),
) func(web.C, http.ResponseWriter, *http.Request)

Wrap wraps a rich handler into a raw Goji handler.

Types

This section is empty.

Jump to

Keyboard shortcuts

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