Documentation
¶
Index ¶
- func DecodeFilesGroupsMapRequest(w http.ResponseWriter, r *http.Request) (maps.FilesGroupsMap, int)
- func DecodeStringRequest(w http.ResponseWriter, r *http.Request, t *string) (*string, int)
- func DecodeStringsRequest(w http.ResponseWriter, r *http.Request, t []string) ([]string, int)
- func DecodeTagMediaMapRequest(w http.ResponseWriter, r *http.Request) (models.TagMediaMap, int)
- func GenerateHTTPClient(caCert string, insecure bool) (*http.Client, *tls.Config)
- func GetUsernameFromHeader(w http.ResponseWriter) string
- func ParseBody(body io.ReadCloser, logfields log.Fields) (string, int)
- func ParsePathID(w http.ResponseWriter, r *http.Request, identifier string) primitive.ObjectID
- func ParsePathString(w http.ResponseWriter, r *http.Request, key string) (string, int)
- func ParseQueryBool(w http.ResponseWriter, r *http.Request, key string, optional bool) (bool, int)
- func ParseQueryString(w http.ResponseWriter, r *http.Request, key string, optional bool) (string, int)
- func ReadCookie(r *http.Request, title string) string
- func RespondWithError(w http.ResponseWriter, code int, message string)
- func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
- func SendRequest(client *http.Client, method string, endpoint string, bearer string, ...) (*http.Response, int, string)
- type ErrorJSON
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeFilesGroupsMapRequest ¶
func DecodeFilesGroupsMapRequest(w http.ResponseWriter, r *http.Request) (maps.FilesGroupsMap, int)
DecodeFilesGroupsMapRequest decodes the api request into a slice responds with decode error if occurs status
0 => ok || status 1 => error
func DecodeStringRequest ¶
DecodeStringRequest decodes the api request into the passed slice defers request.body.close responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeStringsRequest ¶
DecodeStringsRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func DecodeTagMediaMapRequest ¶
func DecodeTagMediaMapRequest(w http.ResponseWriter, r *http.Request) (models.TagMediaMap, int)
DecodeTagMediaMapRequest decodes the api request into the passed slice responds with decode error if occurs status 0 => ok || status 1 => error
func GenerateHTTPClient ¶
GenerateHTTPClient parses the passed cert and adds it to the certpool of a custom http client. if insecure enabled, it skips cert validation.
func GetUsernameFromHeader ¶
func GetUsernameFromHeader(w http.ResponseWriter) string
GetUsernameFromHeader returns the "user" header value
func ParseBody ¶
ParseBody parses the passed readcloser to a string
0 -> ok || 1 -> could not parse body
func ParsePathID ¶
ParsePathID parses the id from the route and returns it returns primitive.NilObjectID if an error occured sends a respond if an error occured
func ParsePathString ¶
ParsePathString parses the string value from the route and returns it stats 0 -> ok || status 1 -> error
func ParseQueryBool ¶
ParseQueryBool parses the string value from the route and converts it into bool. If Optional true and value not set, it defaults to false 0 -> ok 1 -> could not parse string 2 -> could not convert to bool
func ParseQueryString ¶
func ParseQueryString(w http.ResponseWriter, r *http.Request, key string, optional bool) (string, int)
ParseQueryString parses the string value from the route and returns it stats 0 -> ok status 1 -> error
func ReadCookie ¶
ReadCookie reads the stoken cookie from the request and returns the value
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, code int, message string)
RespondWithError Creates an error payload and adds the error message to be returned
func RespondWithJSON ¶
func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})
RespondWithJSON parses the passed payload and returns it with the specified code to the client