web

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2017 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TokenAuth *jwtauth.JwtAuth
)

Functions

func Authenticator

func Authenticator(next http.Handler) http.Handler

func BodyParser

func BodyParser(body interface{}, maxSize int64) func(next http.Handler) http.Handler

BodyParser loads builder with maxSize and tries to load the message. if for some reason it can't parse the message, it will return an error. if successful, it will put the processed data into context with key 'json_body'

func CopyDataToFile

func CopyDataToFile(in io.Reader, to string) error

CopyDataToFile copies data from given input io.Reader and put it into a given file name.

func JSONValidation

func JSONValidation(jsonObj interface{}) error

JSONValidation accept any struct with json tag. it will returns an error if any field inside that struct has `required` tag value and becomes nil

func JwtSetup

func JwtSetup(secretKey string)

func ParamAsInt64

func ParamAsInt64(r *http.Request, name string) (int64, error)

func ParamAsString

func ParamAsString(r *http.Request, name string) string

func Respond

func Respond(w http.ResponseWriter, status int, v interface{})

Respond is a utility function which helps identifies error from other messages

func SetJWTCookie

func SetJWTCookie(w http.ResponseWriter, r *http.Request, value string)

func StreamJSONToStruct

func StreamJSONToStruct(r io.Reader, v interface{}) error

StreamJSONToStruct converts stream of json to a defined struct

func StreamJSONToStructWithLimit

func StreamJSONToStructWithLimit(r io.Reader, v interface{}, limit int64) error

StreamJSONToStructWithLimit similar to StreamJSONToStruct but with limit in payload size

func UUID

func UUID() string

func WriteAsJSON

func WriteAsJSON(w http.ResponseWriter, response interface{}, status int)

WriteAsJSON a helper function to simplifies the JSON serilization

func WriteAsText

func WriteAsText(w http.ResponseWriter, response interface{}, status int)

WriteAsText a helper function to simplifies the string serilization

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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