Documentation ¶
Index ¶
Constants ¶
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-IP" HeaderXRequestID = "X-Request-ID" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderSimulatorUserID = "Simulator-Actor-ID" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderXCSRFToken = "X-CSRF-Token" // #nosec HeaderReferrerPolicy = "Referrer-Policy" HeaderReferer = "Referer" )
Headers
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8 MIMETextXML = "text/xml" MIMETextXMLCharsetUTF8 = MIMETextXML + "; " + charsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" )
MIME types
const ( // PROPFIND Method can be used on collection and property resources. PROPFIND = "PROPFIND" // REPORT Method can be used to get information about a resource, see rfc 3253 REPORT = "REPORT" )
Variables ¶
var ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType)
Functions ¶
Types ¶
type BindUnmarshaler ¶
type BindUnmarshaler interface { // UnmarshalParam decodes and assigns a value from an form or query param. UnmarshalParam(param string) error }
BindUnmarshaler is the interface used to wrap the UnmarshalParam method. Types that don't implement this, but do implement encoding.TextUnmarshaler will use that interface instead.
type GetResultData ¶
type GetResultData struct { // Contains query param passed by client. // To cross check if server accept the correct param from client. Param interface{} `json:"http_param"` // Defines the current API response generated. GeneratedDate string `json:"generated_date"` // Describes total number of data generated by current request. TotalData string `json:"total_data"` // Request result data. Data interface{} `json:"data"` }
GetResultData is the default response result data format. For method GET.
type HTTPError ¶
type HTTPError struct { Code int `json:"-"` Message interface{} `json:"message"` Internal error `json:"-"` // Stores the error returned by an external dependency }
HTTPError represents an error that occurred while handling a request.
func NewHTTPError ¶
NewHTTPError creates a new HTTPError instance.
func (*HTTPError) SetInternal ¶
SetInternal sets error to HTTPError.Internal
type PostResultData ¶
type PostResultData struct { // Contains json body passed by client. // To cross check if server accept the correct param from client. Param interface{} `json:"http_param"` // Defines the current API request execution time. ExecutedDate string `json:"executed_date"` // Describes total number of data is affected by current request. RowsAffected int `json:"rows_affected"` }
PostResultData is the default response result data format. For method PUT, PATCH, POST, DELETE.
type Response ¶
type Response struct { // Describes api status or response code. Code string `json:"api_code"` // Describes status message that should be shown to user. DisplayMsg string `json:"api_display_message"` // Describes server real error message that should not be shown to user. RawMsg string `json:"api_raw_message"` // Used for debugging. // It uses client request `X-Request-ID` header. // If empty, generated by server instead. RequestID string `json:"trace_id"` // Describes current api generated result data. ResultData interface{} `json:"api_result_data"` }
Response is the default response format.
func GetDefaultResponse ¶
GetDefaultResponse is the default response for http get request
func GetSuccessResponse ¶
GetSuccessResponse is the success response for http get request
func PostDefaultResponse ¶
PostDefaultResponse is the default response for http post request
type Writer ¶
type Writer struct { http.ResponseWriter StatusCode int // Response contains the whole operation response data. // Since certain operation has a big response data, // response will only be filled on [development, staging] environment. Response map[string]interface{} }
func NewWriter ¶
func NewWriter(w http.ResponseWriter) *Writer