Documentation ¶
Index ¶
- Variables
- type ExtendedHandler
- type Field
- type FieldList
- type FieldMap
- func (t FieldMap) BaseName() string
- func (t FieldMap) Check(value interface{}) bool
- func (t FieldMap) Convert(value interface{}) (interface{}, error)
- func (t FieldMap) Load(data map[string]interface{}) map[string]interface{}
- func (t FieldMap) SortedKeys() []string
- func (t FieldMap) TypeName() string
- func (t FieldMap) Validate(data map[string]interface{}) (map[string]interface{}, error)
- type Function
- type Response
- type SimpleHandler
- type Type
Constants ¶
This section is empty.
Variables ¶
var Any = &anyType{}
Any is used for undefined/irrelevant types
var Bool = &basicType{boolT, "bool", "boolean"}
Bool represents basic bool types
var Error = &errorType{}
Error is used for errors types
var Float32 = &basicType{float32T, "float32", "number"}
Float32 represents basic float32 types
var Float64 = &basicType{float64T, "float64", "number"}
Float64 represents basic float64 types
var Int = &basicType{intT, "int", "integer"}
Int represents basic int types
var Int16 = &basicType{int16T, "int16", "integer"}
Int16 represents basic int16 types
var Int32 = &basicType{int32T, "int32", "integer"}
Int32 represents basic int32 types
var Int64 = &basicType{int64T, "int64", "integer"}
Int64 represents basic int64 types
var Int8 = &basicType{int8T, "int8", "integer"}
Int8 represents basic int8 types
var Integers = []Type{ Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, }
Integers contains a list of all integer types
var InvalidRequestResponse = Response{ Description: "invalid request", Data: FieldMap{ "error": { Type: String, Description: "Error message", Required: true, }, }, }
InvalidRequestResponse defines response for invalid/failed requests
var Numbers = []Type{ Int, Int8, Int16, Int32, Int64, Uint, Uint8, Uint16, Uint32, Uint64, Float32, Float64, }
Numbers contains a list of all numeric types
var String = &basicType{stringT, "string", "string"}
String represents basic string types
var Uint = &basicType{uintT, "uint", "integer"}
Uint represents basic uint types
var Uint16 = &basicType{uint16T, "uint16", "integer"}
Uint16 represents basic uint16 types
var Uint32 = &basicType{uint32T, "uint32", "integer"}
Uint32 represents basic uint32 types
var Uint64 = &basicType{uint64T, "uint64", "integer"}
Uint64 represents basic uint64 types
var Uint8 = &basicType{uint8T, "uint8", "integer"}
Uint8 represents basic uint8 types
Functions ¶
This section is empty.
Types ¶
type ExtendedHandler ¶
type ExtendedHandler struct { Description string Parameters FieldMap Responses map[string]Response }
ExtendedHandler definition
func (*ExtendedHandler) ValidateParameters ¶
func (f *ExtendedHandler) ValidateParameters(data map[string]interface{}) (map[string]interface{}, error)
ValidateParameters check if data matches with defined parameters and add defaults to data
type Field ¶
type Field struct { // Type of value // 0/Invalid for undefined/any type Type Type // Description of field Description string // True if field is required Required bool // Default value if field is not required DefaultValue interface{} // Order index of field (should not be 0 if used) Order uint // Possible values for this field // key: value for field // value: description of value (or value as fallback) PossibleValues func() map[interface{}]string // True if only values from PossibleValues are valid OnlyPossibleValues bool }
Field information for a value
func (Field) MarshalJSON ¶
MarshalJSON converts Field to JSON
type FieldList ¶
type FieldList []Field
FieldList type with list of fields
type FieldMap ¶
FieldMap type with sub fields
func (FieldMap) SortedKeys ¶
SortedKeys returns list with sorted map keys (uses Order if set)
type Function ¶
type Function struct { Description string Arguments FieldMap // order should be defined Response FieldList }
Function with positional arguments and response
func (*Function) ValidateArguments ¶
ValidateArguments check if data matches with defined parameters and add defaults to data
type SimpleHandler ¶
SimpleHandler with named parameters and a single response
func (*SimpleHandler) ValidateParameters ¶
func (f *SimpleHandler) ValidateParameters(data map[string]interface{}) (map[string]interface{}, error)
ValidateParameters check if data matches with defined parameters and add defaults to data
type Type ¶
type Type interface { // Convert given value to type if possible Convert(value interface{}) (interface{}, error) // Check if the value matches the type Check(value interface{}) bool // TypeName return the name of the type TypeName() string // BaseName return the name of the type category BaseName() string }
Type defines base interface of types
func TypeFromTypeName ¶
TypeFromTypeName returns type from type name