Documentation ¶
Overview ¶
Package util provides utilities which includes type conversion, HTTP shortcuts, string manipulcation & time parsing.
Index ¶
- func HTTPAbort(w http.ResponseWriter, message string, code int)
- func HTTPRespond(w http.ResponseWriter, data []byte)
- func HTTPRespondJSON(w http.ResponseWriter, message string, data interface{})
- func Int64FromString(s string) (int64, error)
- func NormalizeString(str string) string
- func ParseDuration(str string) (duration time.Duration, err error)
- func ReverseAny(s interface{})
- type HTTPError
- type HTTPResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPAbort ¶
func HTTPAbort(w http.ResponseWriter, message string, code int)
HTTPAbort writes headers and JSON body with corresponding message and code.
func HTTPRespond ¶
func HTTPRespond(w http.ResponseWriter, data []byte)
HTTPRespond writes body with HTTP code of 200.
func HTTPRespondJSON ¶
func HTTPRespondJSON(w http.ResponseWriter, message string, data interface{})
HTTPRespondJSON writes headers and JSON body.
func Int64FromString ¶
Int64FromString interprets a string s in base 64 with bit size of 64.
func NormalizeString ¶
NormalizeString transforms an unicode string str to ASCII form.
func ParseDuration ¶
ParseDuration parses a duration string.
func ReverseAny ¶ added in v0.1.1
func ReverseAny(s interface{})
ReverseAny takes a slice of anything and reverse it.
Types ¶
type HTTPResponse ¶
type HTTPResponse struct { HTTPError `json:",inline"` Data interface{} `json:"data"` }
HTTPResponse represents a response with data and error.
Click to show internal directories.
Click to hide internal directories.