Documentation ¶
Index ¶
- Variables
- func Authenticator(next http.Handler) http.Handler
- func BodyParser(body interface{}, maxSize int64) func(next http.Handler) http.Handler
- func CopyDataToFile(in io.Reader, to string) error
- func JSONValidation(jsonObj interface{}) error
- func JwtSetup(secretKey string)
- func ParamAsInt64(r *http.Request, name string) (int64, error)
- func ParamAsString(r *http.Request, name string) string
- func Respond(w http.ResponseWriter, status int, v interface{})
- func SetJWTCookie(w http.ResponseWriter, r *http.Request, value string)
- func StreamJSONToStruct(r io.Reader, v interface{}) error
- func StreamJSONToStructWithLimit(r io.Reader, v interface{}, limit int64) error
- func UUID() string
- func WriteAsJSON(w http.ResponseWriter, response interface{}, status int)
- func WriteAsText(w http.ResponseWriter, response interface{}, status int)
Constants ¶
This section is empty.
Variables ¶
var (
TokenAuth *jwtauth.JwtAuth
)
Functions ¶
func BodyParser ¶
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 ¶
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 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 ¶
StreamJSONToStruct converts stream of json to a defined struct
func StreamJSONToStructWithLimit ¶
StreamJSONToStructWithLimit similar to StreamJSONToStruct but with limit in payload size
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.