Documentation ¶
Index ¶
- func AccessMiddlewareFactory(secret string) func(http.Handler) http.Handler
- func ApplySkipLimit(query *mdb.Query, skip *int, limit *int) *mdb.Query
- func BoolParameterFromRequest(r *http.Request, name string) *bool
- func ConvertMapToValue(value interface{}, jsonMap map[string]interface{}) error
- func DefaultMiddlewaresFactory(secret string) func(http.Handler) http.Handler
- func Find(collection *mdb.Collection, q bson.M, skip *int, limit *int) (*interface{}, int)
- func FloatParameterFromRequest(r *http.Request, name string) *float64
- func GetBody(req *http.Request) (map[string]interface{}, error)
- func GetObjectIdFromURLInRequest(r *http.Request, key string) *bson.ObjectId
- func GetValidatedBody(req *http.Request, validatorMap VMap) (map[string]interface{}, error)
- func GetValidatedURLParameters(req *http.Request, validatorMap VMap) (map[string]interface{}, error)
- func GetValueFromURLInRequest(r *http.Request, key string) *string
- func IntParameterFromRequest(r *http.Request, name string) *int
- func JSON(w http.ResponseWriter, value interface{}, code int)
- func LoggingMiddleware(next http.Handler) http.Handler
- func MapKeys(m VMap) []string
- func Now() int64
- func RandStringBytes(n int) string
- func RecoverMiddleware(next http.Handler) http.Handler
- func SetInContext(value interface{}, key interface{}, req *http.Request) *http.Request
- func UnwrapOrDefaultBool(value *bool, d bool) bool
- func UnwrapOrDefaultInt(value *int, d int) int
- func UnwrapOrDefaultString(value *string, d string) string
- func ValidateBody(body map[string]interface{}, validatorMap VMap) (map[string]interface{}, error)
- func WriteResponseOrError(w http.ResponseWriter, code int, response interface{}, err error)
- type Error
- type Errors
- type FloatRange
- type Int64Range
- type IntRange
- type Router
- func (self *Router) Delete(path string, handler http.Handler)
- func (self *Router) Get(path string, handler http.Handler)
- func (self *Router) Post(path string, handler http.Handler)
- func (self *Router) Put(path string, handler http.Handler)
- func (self *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- type ServerError
- type VMap
- type Validator
- func ArrayValidator(key string) Validator
- func BoolValidator(key string) Validator
- func CountryValidator(key string) Validator
- func DateTimeValidator(key string, t *time.Time) Validator
- func FloatInRangeValidator(key string, floatRange FloatRange) Validator
- func FloatValidator(key string) Validator
- func Int64InRangeValidator(key string, intRange Int64Range) Validator
- func IntInRangeValidator(key string, intRange IntRange) Validator
- func IntValidator(key string) Validator
- func LanguageValidator(key string) Validator
- func NotEmptyValidator(key string) Validator
- func ObjectIDValidator(key string) Validator
- func RequiredBoolValidators(key string, validators ...Validator) []Validator
- func RequiredFloatValidators(key string, validators ...Validator) []Validator
- func RequiredIntValidators(key string, validators ...Validator) []Validator
- func RequiredStringValidators(key string, validators ...Validator) []Validator
- func SexValidator(key string) Validator
- func StringArrayValidator(key string, each []Validator) Validator
- func StringContainsValidator(key string, values []string) Validator
- func StringLengthValidator(length int, key string) Validator
- func StringValidator(key string) Validator
- func TimezoneValidator(key string) Validator
- func URLValidator(key string) Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessMiddlewareFactory ¶
func ConvertMapToValue ¶
func GetValidatedBody ¶
func JSON ¶
func JSON(w http.ResponseWriter, value interface{}, code int)
func RandStringBytes ¶
func SetInContext ¶
func UnwrapOrDefaultBool ¶
func UnwrapOrDefaultInt ¶
func UnwrapOrDefaultString ¶
func ValidateBody ¶
func WriteResponseOrError ¶
func WriteResponseOrError(w http.ResponseWriter, code int, response interface{}, err error)
Types ¶
type Error ¶
type Error struct { Key string `json:"key"` Description string `json:"description"` Code string `json:"code"` Args []string `json:"args, omitempty"` }
func UndefinedKeyError ¶
func ValidateMap ¶
func ValidateValue ¶
func (Error) AsServerError ¶
func (Error) WriteWithCode ¶
func (self Error) WriteWithCode(code int, w http.ResponseWriter)
type FloatRange ¶
type Int64Range ¶
type ServerError ¶
func HTTP400 ¶
func HTTP400() ServerError
func HTTP401 ¶
func HTTP401() ServerError
func HTTP403 ¶
func HTTP403() ServerError
func HTTP404 ¶
func HTTP404(id string) ServerError
func (ServerError) Error ¶
func (self ServerError) Error() string
func (ServerError) Write ¶
func (self ServerError) Write(w http.ResponseWriter)
type Validator ¶
type Validator func(value interface{}) error
func ArrayValidator ¶
func BoolValidator ¶
func CountryValidator ¶
func FloatInRangeValidator ¶
func FloatInRangeValidator(key string, floatRange FloatRange) Validator
func FloatValidator ¶
func Int64InRangeValidator ¶
func Int64InRangeValidator(key string, intRange Int64Range) Validator
func IntInRangeValidator ¶
func IntValidator ¶
func LanguageValidator ¶
func NotEmptyValidator ¶
func ObjectIDValidator ¶
func RequiredBoolValidators ¶
func RequiredFloatValidators ¶
func RequiredIntValidators ¶
func SexValidator ¶
func StringArrayValidator ¶
func StringContainsValidator ¶
func StringLengthValidator ¶
func StringValidator ¶
func TimezoneValidator ¶
func URLValidator ¶
Click to show internal directories.
Click to hide internal directories.