Documentation ¶
Index ¶
- Constants
- Variables
- func ExtractBearerToken(r *http.Request) string
- func ExtractThingKey(r *http.Request) string
- func LoggingErrorEncoder(logger logger.Logger, enc kithttp.ErrorEncoder) kithttp.ErrorEncoder
- func ReadBoolQuery(r *http.Request, key string, def bool) (bool, error)
- func ReadFloatQuery(r *http.Request, key string, def float64) (float64, error)
- func ReadIntQuery(r *http.Request, key string, def int64) (int64, error)
- func ReadLimitQuery(r *http.Request, key string, def uint64) (uint64, error)
- func ReadMetadataQuery(r *http.Request, key string, def map[string]interface{}) (map[string]interface{}, error)
- func ReadStringQuery(r *http.Request, key string, def string) (string, error)
- func ReadUintQuery(r *http.Request, key string, def uint64) (uint64, error)
- type ErrorRes
- type Response
Constants ¶
const BearerPrefix = "Bearer "
BearerPrefix represents the token prefix for Bearer authentication scheme.
const ThingPrefix = "Thing "
ThingPrefix represents the key prefix for Thing authentication scheme.
Variables ¶
var ( // ErrBearerToken indicates missing or invalid bearer user token. ErrBearerToken = errors.New("missing or invalid bearer user token") // ErrBearerKey indicates missing or invalid bearer entity key. ErrBearerKey = errors.New("missing or invalid bearer entity key") // ErrMissingID indicates missing entity ID. ErrMissingID = errors.New("missing entity id") // ErrMissingGroupID indicates missing group ID. ErrMissingGroupID = errors.New("missing group id") // ErrMissingOrgID indicates missing org ID. ErrMissingOrgID = errors.New("missing org id") // ErrMissingRole indicates missing role. ErrMissingRole = errors.New("missing role") // ErrMissingObject indicates missing object. ErrMissingObject = errors.New("missing object") // ErrMissingSubject indicates invalid subject. ErrInvalidSubject = errors.New("invalid subject") // ErrInvalidAction indicates invalid action. ErrInvalidAction = errors.New("invalid action") // ErrInvalidAuthKey indicates invalid auth key. ErrInvalidAuthKey = errors.New("invalid auth key") // ErrInvalidIDFormat indicates an invalid ID format. ErrInvalidIDFormat = errors.New("invalid id format provided") // ErrNameSize indicates that name size exceeds the max. ErrNameSize = errors.New("invalid name size") // ErrEmailSize indicates that email size exceeds the max. ErrEmailSize = errors.New("invalid email size") // ErrInvalidStatus indicates an invalid user account status. ErrInvalidStatus = errors.New("invalid user account status") // ErrLimitSize indicates that an invalid limit. ErrLimitSize = errors.New("invalid limit size") // ErrOffsetSize indicates an invalid offset. ErrOffsetSize = errors.New("invalid offset size") // ErrInvalidOrder indicates an invalid list order. ErrInvalidOrder = errors.New("invalid list order provided") // ErrInvalidDirection indicates an invalid list direction. ErrInvalidDirection = errors.New("invalid list direction provided") // ErrEmptyList indicates that entity data is empty. ErrEmptyList = errors.New("empty list provided") // ErrMissingCertData indicates missing cert data (ttl, key_type or key_bits). ErrMissingCertData = errors.New("missing certificate data") // ErrInvalidTopic indicates an invalid subscription topic. ErrInvalidTopic = errors.New("invalid Subscription topic") // ErrInvalidContact indicates an invalid contact. ErrInvalidContact = errors.New("invalid contact") // ErrMissingEmail indicates missing email. ErrMissingEmail = errors.New("missing email") // ErrMissingHost indicates missing host. ErrMissingHost = errors.New("missing host") // ErrMissingPass indicates missing password. ErrMissingPass = errors.New("missing password") // ErrMissingConfPass indicates missing conf password. ErrMissingConfPass = errors.New("missing conf password") // ErrInvalidResetPass indicates an invalid reset password. ErrInvalidResetPass = errors.New("invalid reset password") // ErrInvalidComparator indicates an invalid comparator. ErrInvalidComparator = errors.New("invalid comparator") // ErrMissingMemberType indicates missing group member type. ErrMissingMemberType = errors.New("missing group member type") // ErrInvalidAPIKey indicates an invalid API key type. ErrInvalidAPIKey = errors.New("invalid api key type") // ErrMaxLevelExceeded indicates an invalid group level. ErrMaxLevelExceeded = errors.New("invalid group level (should be lower than 5)") // ErrUnsupportedContentType indicates unacceptable or lack of Content-Type ErrUnsupportedContentType = errors.New("unsupported content type") // ErrInvalidQueryParams indicates invalid query parameters ErrInvalidQueryParams = errors.New("invalid query parameters") // ErrNotFoundParam indicates that the parameter was not found in the query ErrNotFoundParam = errors.New("parameter not found in the query") // ErrInvalidMemberRole indicates an invalid member role. ErrInvalidMemberRole = errors.New("invalid member role") // ErrMalformedEntity indicates a malformed entity specification. ErrMalformedEntity = errors.New("malformed entity specification") // ErrInvalidRole indicates an invalid role. ErrInvalidRole = errors.New("invalid role") )
Errors defined in this file are used by the LoggingErrorEncoder decorator to distinguish and log API request validation errors and avoid that service errors are logged twice.
Functions ¶
func ExtractBearerToken ¶
ExtractBearerToken returns value of the bearer token. If there is no bearer token - an empty value is returned.
func ExtractThingKey ¶
ExtractThingKey returns value of the thing key. If there is no thing key - an empty value is returned.
func LoggingErrorEncoder ¶
func LoggingErrorEncoder(logger logger.Logger, enc kithttp.ErrorEncoder) kithttp.ErrorEncoder
LoggingErrorEncoder is a go-kit error encoder logging decorator.
func ReadBoolQuery ¶
ReadBoolQuery reads boolean query parameters in a given http request
func ReadFloatQuery ¶
ReadFloatQuery reads the value of float64 http query parameters for a given key
func ReadIntQuery ¶
ReadIntQuery reads the value of int64 http query parameters for a given key
func ReadLimitQuery ¶
ReadLimitQuery reads the value of limit http query parameters
func ReadMetadataQuery ¶
func ReadMetadataQuery(r *http.Request, key string, def map[string]interface{}) (map[string]interface{}, error)
ReadMetadataQuery reads the value of json http query parameters for a given key
func ReadStringQuery ¶
ReadStringQuery reads the value of string http query parameters for a given key