Documentation ¶
Index ¶
Constants ¶
const ( // ContentTypeJSON Content type for JSON ContentTypeJSON string = "application/json; charset=utf-8" // ContentTypeXML Content type for XML ContentTypeXML = "application/xml; charset=utf-8" // ContentTypeRssXML Content type for RSS ContentTypeRssXML = "application/rss+xml; charset=utf-8" // ContentTypeAtomXML Content type for ATOM ContentTypeAtomXML = "application/atom+xml; charset=utf-8" // ContentTypeHTML Content type for HTML ContentTypeHTML = "text/html; charset=utf-8" // ContentTypeProtobuf Content type for ProtoBuf ContentTypeProtobuf = "application/protobuf" )
Variables ¶
This section is empty.
Functions ¶
func WriteResponseBytes ¶
func WriteResponseBytes(ctx *fasthttp.RequestCtx, status int, contentType string, resp []byte)
WriteResponseBytes write response to client with status code, body and content type
func WriteResponseString ¶
func WriteResponseString(ctx *fasthttp.RequestCtx, status int, contentType string, resp string)
WriteResponseString write response to client with status code, body and content type
Types ¶
type ErrorHandlerFunction ¶
type ErrorHandlerFunction func(ctx *fasthttp.RequestCtx, err error)
ErrorHandlerFunction type that define function that used to process error from api method
type SVAPI ¶
type SVAPI struct {
// contains filtered or unexported fields
}
SVAPI - main structure
func (*SVAPI) CallAPI ¶
func (as *SVAPI) CallAPI(ctx *fasthttp.RequestCtx, method string)
CallAPI call api method and process it. Modifying body after this function not recommended
func (*SVAPI) GetServiceMap ¶
GetServiceMap returns an api methods list
func (*SVAPI) RegisterService ¶
RegisterService adds a new service to the api server.
The name parameter is optional: if empty it will be inferred from the receiver type name.
Methods from the receiver will be extracted if these rules are satisfied:
- The receiver is exported (begins with an upper case letter) or local (defined in the package registering the service).
- The method name is exported.
- The method has one argument: *fasthttp.RequestCtx.
- All arguments are pointers.
- The method has return type error that will be processed by error handler method.
All other methods are ignored.
func (*SVAPI) SetErrorHandlerFunction ¶ added in v0.5.0
func (as *SVAPI) SetErrorHandlerFunction(errHndl ErrorHandlerFunction)
SetErrorHandlerFunction allows to set custom error handler for api function returned error