Documentation ¶
Overview ¶
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
* Copyright (c) 2016 The ConnectorDB Contributors Licensed under the MIT license. *
Index ¶
- Variables
- func Authenticator(apifunc webcore.APIHandler, db *connectordb.Database) http.HandlerFunc
- func BadQ(o *authoperator.AuthOperator, writer http.ResponseWriter, ...) error
- func GetStreamPath(request *http.Request) (username string, devicename string, streamname string, streampath string)
- func IntWriter(writer http.ResponseWriter, i int64, logger *log.Entry, err error) (int, string)
- func JSONWriter(writer http.ResponseWriter, data interface{}, logger *log.Entry, err error) (int, string)
- func OK(writer http.ResponseWriter) error
- func ParseIRange(q url.Values) (int64, int64, error)
- func ParseTRange(q url.Values) (float64, float64, int64, error)
- func UintWriter(writer http.ResponseWriter, i uint64, logger *log.Entry, err error) (int, string)
- func UnmarshalRequest(request *http.Request, unmarshalTo interface{}) error
- func ValidName(n string, err error) error
- func WriteError(writer http.ResponseWriter, logger *log.Entry, errorCode int, err error, ...) (int, string)
- func WriteJSONResult(writer http.ResponseWriter, dr datastream.DataRange, logger *log.Entry, ...) (int, string)
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Authenticator ¶
func Authenticator(apifunc webcore.APIHandler, db *connectordb.Database) http.HandlerFunc
Authenticator runs authentication on a request, making sure that the REST API can handle it
func BadQ ¶
func BadQ(o *authoperator.AuthOperator, writer http.ResponseWriter, request *http.Request, logger *log.Entry) error
BadQ checks if there is a q= part to the given query, and gives an error if there is
func GetStreamPath ¶
func GetStreamPath(request *http.Request) (username string, devicename string, streamname string, streampath string)
GetStreamPath returns the relevant parts of a stream path
func JSONWriter ¶
func JSONWriter(writer http.ResponseWriter, data interface{}, logger *log.Entry, err error) (int, string)
JSONWriter writes the given data as http
func OK ¶
func OK(writer http.ResponseWriter) error
OK is a simplifying function that returns success
func ParseIRange ¶
ParseIRange attempts to parse a request as an index range
func ParseTRange ¶
ParseTRange attempts to parse a request parameters as time range
func UintWriter ¶
UintWriter writes an unsigned integer
func UnmarshalRequest ¶
UnmarshalRequest unmarshals the input data to the given interface
func WriteError ¶
func WriteError(writer http.ResponseWriter, logger *log.Entry, errorCode int, err error, iserr bool) (int, string)
WriteError takes care of gracefully writing errors to the client in a way that allows for fairly easy debugging.
func WriteJSONResult ¶
func WriteJSONResult(writer http.ResponseWriter, dr datastream.DataRange, logger *log.Entry, err error) (int, string)
WriteJSONResult writes a DataRange as a response
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Code int `json:"code"` Message string `json:"msg"` Reference string `json:"ref,omitempty"` }
ErrorResponse is the struct which holds the error message and response code