Documentation ¶
Index ¶
- Constants
- func ErrHandler(handler ErrHandle) httprouter.Handle
- func IsValid(name string) bool
- func LogErr(ctx *log.Entry, err error, reason string)
- func LogFatal(ctx *log.Entry, err error, reason string)
- func LogRequest(handle httprouter.Handle) httprouter.Handle
- func LogWarn(ctx *log.Entry, err error, reason string)
- func RequestContext(req *http.Request) *log.Entry
- func RespondJSON(w http.ResponseWriter, code int, data interface{}) error
- type ErrHandle
- type ErrorResponse
Constants ¶
const Logo = `
___ ___ ___ _ _ ___
| | -_| _| | | .'|
|_|_|___|_| \_/|__,|
`
Logo is the nerva ASCII logo. Generated via http://patorjk.com/software/taag/#p=display&f=Rectangles&t=nerva
Variables ¶
This section is empty.
Functions ¶
func ErrHandler ¶
func ErrHandler(handler ErrHandle) httprouter.Handle
ErrHandler allows custom handlers to return internal server errors.
func IsValid ¶
IsValid checks if the given name is valid according to the CommonJS spec. Besides the addition of fields to the Package Version Object, this addition to the Packages spec imposes the following restrictions on the “name” and “version” fields: 1. MUST NOT start with “-“ 2. MUST NOT contain any “/” characters 3. MUST NOT be “.” or “..” 4. SHOULD contain only URL-safe characters See http://wiki.commonjs.org/wiki/Packages/Registry#Changes_to_Packages_Spec
func LogRequest ¶
func LogRequest(handle httprouter.Handle) httprouter.Handle
func RespondJSON ¶
func RespondJSON(w http.ResponseWriter, code int, data interface{}) error
RespondJSON encodes the passed in data as JSON-compatible string and returns it to the client.
Types ¶
type ErrHandle ¶
type ErrHandle func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) error
ErrHandle is a custom HTTP handle that can optionally return an error.
func ValidatePropHandler ¶
ValidatePropHandler validates the passed in property names.
type ErrorResponse ¶
ErrorResponse is a HTTP response.