fast

package
v0.0.0-...-48af17f Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(ctx *fasthttp.RequestCtx, err error) error

Err writes the provided error to the response

func Handler

func Handler(handler HTTPHandlerFunc) fasthttp.RequestHandler

Handler wraps a library handler func nto a fasthttp handler func

func JSON

func JSON(ctx *fasthttp.RequestCtx, status int, result interface{}) error

JSON writes the provided json media to the response

func ProtoBuff

func ProtoBuff(ctx *fasthttp.RequestCtx, status int, result interface{}) error

ProtoBuff writes the provided protocol buffer media to the response

func ReadByContentType

func ReadByContentType(ctx *fasthttp.RequestCtx, data interface{}) error

ReadByContentType reads data from context using the Content-Type header to define the media type

func ReadJSON

func ReadJSON(ctx *fasthttp.RequestCtx, data interface{}) error

ReadJSON unmarshals from provided context a json media into data

func ReadProtoBuff

func ReadProtoBuff(ctx *fasthttp.RequestCtx, data interface{}) error

ReadProtoBuff unmarshals from provided context a protocol buffer media into data

func Status

func Status(ctx *fasthttp.RequestCtx, status int) error

Status writes the provided status to the response

func WriteByAccept

func WriteByAccept(ctx *fasthttp.RequestCtx, status int, result interface{}) error

WriteByAccept writes data to context using the Accept header to define the media type

Types

type BaseHandler

type BaseHandler struct {
}

BaseHandler is a struct to add response helper function to other handlers

func (BaseHandler) Err

func (h BaseHandler) Err(ctx *fasthttp.RequestCtx, err error) error

Err writes a error to response

func (BaseHandler) JSON

func (h BaseHandler) JSON(ctx *fasthttp.RequestCtx, status int, result interface{}) error

JSON writes a json media to response

func (BaseHandler) Status

func (h BaseHandler) Status(ctx *fasthttp.RequestCtx, status int) error

Status writes the provided status to response

type ErrorHandler

type ErrorHandler func(context.Context, *fasthttp.RequestCtx) error

ErrorHandler is a helper type to add exception control to other handlers

func (ErrorHandler) HandleRequest

func (h ErrorHandler) HandleRequest(c context.Context, fc *fasthttp.RequestCtx) error

HandleRequest is the HTTPHandler contract

type HTTPHandler

type HTTPHandler interface {
	HandleRequest(context.Context, *fasthttp.RequestCtx) error
}

HTTPHandler is a contract for fast http handlers

type HTTPHandlerFunc

type HTTPHandlerFunc func(context.Context, *fasthttp.RequestCtx) error

HTTPHandlerFunc is a function to handle fasthttp requrests

func Error

func Error(handler HTTPHandlerFunc) HTTPHandlerFunc

Error wraps the provided HTTPHandlerFunc with exception control

func Log

func Log(handler HTTPHandlerFunc) HTTPHandlerFunc

Log wraps the provided HTTPHandlerFunc with access logging control

func (HTTPHandlerFunc) HandleRequest

func (h HTTPHandlerFunc) HandleRequest(c context.Context, fc *fasthttp.RequestCtx) error

HandleRequest is the contract with HTTPHandler interface

type LogHandler

type LogHandler func(context.Context, *fasthttp.RequestCtx) error

LogHandler is a helper type to add access logging control to other handlers

func (LogHandler) HandleRequest

func (h LogHandler) HandleRequest(c context.Context, fc *fasthttp.RequestCtx) error

HandleRequest is the HTTPHandler contract

type SimpleHTTPHandler

type SimpleHTTPHandler interface {
	HandleRequest(*fasthttp.RequestCtx)
}

SimpleHTTPHandler is a contract for fast http handlers

Jump to

Keyboard shortcuts

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