Documentation
¶
Overview ¶
Package common implements some utility functions for http transaction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBodyFromReq ¶
GetBodyFromReq reads a body from http request object. A successful call returns the body type of string. If request does not include body, InvalidParam will be returned. In other cases, an appropriate error will be returned.
func MapToJsonByte ¶
ChangeToJson converts map to []byte.
func WriteError ¶
func WriteError(w http.ResponseWriter, err error)
WriteError writes the data to the connection as part of an HTTP reply. The http status code depend on an error type. An error message will be included as a body.
func WriteResponse ¶
func WriteResponse(w http.ResponseWriter, code int, data []byte)
WriteResponse calls WriteSuccess or WriteResponse function to respond to the request. If err is nil, WriteSuccess will be called. otherwise, WriteError will be called.
Types ¶
This section is empty.