Documentation
¶
Index ¶
- Constants
- func DoHandleData(ct string, data []byte) http.HandlerFunc
- func DoHandleJSON(v interface{}) http.HandlerFunc
- func DoHandleJSONData(data []byte) http.HandlerFunc
- func ErrorToStatus(err error) int
- func IsValidURL(rawURL string) error
- func LimitReadAll(in io.Reader, limit int) ([]byte, error)
- func NormalizeRemoteBaseURL(mattermostSiteURL, remoteURL string) (string, error)
- func ProcessResponseError(w http.ResponseWriter, resp *http.Response, err error) bool
- func ReadAndClose(in io.ReadCloser) ([]byte, error)
- func WriteErrorIfNeeded(w http.ResponseWriter, err error)
- func WriteJSON(w http.ResponseWriter, v interface{}) error
- func WriteJSONStatus(w http.ResponseWriter, statusCode int, v interface{}) error
- type Handler
- type LimitReadCloser
Constants ¶
View Source
const InLimit = 10 * (1 << 20)
Variables ¶
This section is empty.
Functions ¶
func DoHandleData ¶ added in v1.0.0
func DoHandleData(ct string, data []byte) http.HandlerFunc
DoHandleData returns an http.HandleFunc that serves a data chunk with a specified content-type.
func DoHandleJSON ¶ added in v1.0.0
func DoHandleJSON(v interface{}) http.HandlerFunc
DoHandleJSON returns an http.HandleFunc that serves a data chunk with a specified content-type.
func DoHandleJSONData ¶ added in v1.0.0
func DoHandleJSONData(data []byte) http.HandlerFunc
DoHandleJSONData returns an http.HandleFunc that serves a JSON-encoded data chunk.
func ErrorToStatus ¶ added in v1.0.0
func IsValidURL ¶ added in v1.0.0
IsValidURL checks if a given URL is a valid URL with a host and a http or http scheme.
func NormalizeRemoteBaseURL ¶
func ProcessResponseError ¶
func ReadAndClose ¶
func ReadAndClose(in io.ReadCloser) ([]byte, error)
func WriteErrorIfNeeded ¶ added in v1.2.0
func WriteErrorIfNeeded(w http.ResponseWriter, err error)
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v interface{}) error
WriteJSON encodes and writes out an object, with a 200 response status code.
func WriteJSONStatus ¶
func WriteJSONStatus(w http.ResponseWriter, statusCode int, v interface{}) error
WriteJSONStatus encodes and writes out an object, with a custom response status code.
Types ¶
type LimitReadCloser ¶
type LimitReadCloser struct { ReadCloser io.ReadCloser TotalRead utils.ByteSize Limit utils.ByteSize OnClose func(*LimitReadCloser) error }
func (*LimitReadCloser) Close ¶
func (r *LimitReadCloser) Close() error
Click to show internal directories.
Click to hide internal directories.