Documentation
¶
Index ¶
- Variables
- func ReadRequest(r *http.Request, obj interface{}) error
- func Respond(w http.ResponseWriter, obj interface{})
- func RespondBytesWithCode(w http.ResponseWriter, code int, bs []byte)
- func RespondJSONObjectWithCode(w http.ResponseWriter, code int, obj interface{})
- func RespondWithBadRequest(w http.ResponseWriter, err error)
- func RespondWithError(w http.ResponseWriter, err error)
- func RespondWithJSONBytes(w http.ResponseWriter, jsonBytes []byte, err error)
- func RespondWithJSONObject(w http.ResponseWriter, jsonObj interface{})
- type AQLRequest
- type AQLResponse
- type ErrorResponse
- type NoContentResponse
- type RequestContext
- type SQLRequest
- type StringArrayResponse
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMsgFailedToUnmarshalRequest represents error message for unmarshal error. ErrMsgFailedToUnmarshalRequest = "Bad request: failed to unmarshal request body" // ErrMsgMissingParameter represents error message for missing params error. ErrMsgMissingParameter = "Bad request: missing/invalid parameter" // ErrMsgFailedToReadRequestBody represents error message for unable to read request body error. ErrMsgFailedToReadRequestBody = "Bad request: failed to read request body" // ErrMsgNonExistentTable represents error message for table does not exist ErrMsgNonExistentTable = "Bad request: table does not exist" // ErrMsgNonExistentColumn represents error message for column does not exist ErrMsgNonExistentColumn = "Bad request: column does not exist" // ErrMsgDeletedColumn represents error message for column is already deleted ErrMsgDeletedColumn = "Bad request: column is already deleted" // ErrMsgNotImplemented represents error message for method not implemented. ErrMsgNotImplemented = "Not implemented" // ErrMsgFailedToJSONMarshalResponseBody respresents error message for failure to marshal // response body into json. ErrMsgFailedToJSONMarshalResponseBody = "Failed to marshal the response body into json" // ErrMissingParameter represents api error for missing parameter ErrMissingParameter = utils.APIError{ Code: http.StatusBadRequest, Message: ErrMsgMissingParameter, } // ErrNotImplemented represents api error for method not implemented. ErrNotImplemented = utils.APIError{ Code: http.StatusNotImplemented, Message: ErrMsgNotImplemented, } // ErrTableDoesNotExist represents api error for table does not exist. ErrTableDoesNotExist = utils.APIError{ Code: http.StatusBadRequest, Message: ErrMsgNonExistentTable, } // ErrColumnDoesNotExist represents api error for column does not exist. ErrColumnDoesNotExist = utils.APIError{ Code: http.StatusBadRequest, Message: ErrMsgNonExistentColumn, } // ErrColumnDeleted represents api error for column is already deleted. ErrColumnDeleted = utils.APIError{ Code: http.StatusBadRequest, Message: ErrMsgDeletedColumn, } // ErrBatchDoesNotExist represents api error for batch does not exist. ErrBatchDoesNotExist = utils.APIError{ Code: http.StatusBadRequest, Message: "Bad request: batch does not exist", } // ErrFailedToJSONMarshalResponseBody represents the api error for failure to marshal // response body into json. ErrFailedToJSONMarshalResponseBody = utils.APIError{ Code: http.StatusInternalServerError, Message: ErrMsgFailedToJSONMarshalResponseBody, } )
Functions ¶
func ReadRequest ¶
ReadRequest reads request. obj passed into this method has to be a pointer to a struct of request object Each request object will have path params tagged as `path:""` if needed and post body tagged as `body:""` if needed path tag must have parameter name, which will be used to read path param body tag field has to be a struct. eg.
type AddEnumCaseRequest struct {
TableName string `path:"table"`
ColumnName string `path:"column"`
Body struct {
EnumCase string `json:"enumCase"`
} `body:""`
}
func Respond ¶
func Respond(w http.ResponseWriter, obj interface{})
Respond responds with object with success status
func RespondBytesWithCode ¶
func RespondBytesWithCode(w http.ResponseWriter, code int, bs []byte)
RespondBytesWithCode with specified code and bytes.
func RespondJSONObjectWithCode ¶
func RespondJSONObjectWithCode(w http.ResponseWriter, code int, obj interface{})
RespondJSONObjectWithCode with specified code and object.
func RespondWithBadRequest ¶
func RespondWithBadRequest(w http.ResponseWriter, err error)
RespondWithBadRequest responds with StatusBadRequest as code.
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, err error)
RespondWithError responds with error.
func RespondWithJSONBytes ¶
func RespondWithJSONBytes(w http.ResponseWriter, jsonBytes []byte, err error)
RespondWithJSONBytes writes json bytes to response.
func RespondWithJSONObject ¶
func RespondWithJSONObject(w http.ResponseWriter, jsonObj interface{})
RespondWithJSONObject marshals the object into json bytes and write the bytes into response.
Types ¶
type AQLRequest ¶
type AQLRequest struct {
// in: query
Device int `query:"device,optional" json:"device"`
// in: query
Verbose int `query:"verbose,optional" json:"verbose"`
// in: query
Debug int `query:"debug,optional" json:"debug"`
// in: query
Profiling string `query:"profiling,optional" json:"profiling"`
// in: query
Query string `query:"q,optional" json:"q"`
// in: query
DataOnly int `query:"dataonly,optional" json:"dataonly"`
// in: query
DeviceChoosingTimeout int `query:"timeout,optional" json:"timeout"`
// in: header
Accept string `header:"Accept,optional" json:"accept"`
// in: header
Origin string `header:"Rpc-Caller,optional" json:"origin"`
// in: body
Body queryCom.AQLRequest `body:""`
}
AQLRequest represents AQL query request. Debug mode will run **each batch** in synchronized mode and report time for each step. swagger:parameters queryAQL
type AQLResponse ¶
type AQLResponse struct {
//in: body
Body queryCom.AQLResponse
}
AQLResponse represents queryAQL response. swagger:response aqlResponse
type ErrorResponse ¶
ErrorResponse represents error response. swagger:response errorResponse
type NoContentResponse ¶
type NoContentResponse struct{}
NoContentResponse represents Response with no content. swagger:response noContentResponse
type RequestContext ¶
type RequestContext struct {
Device int
Verbose int
Debug int
Profiling string
DeviceChoosingTimeout int
Accept string
Origin string
}
QueryContext contains settings common for all requests
type SQLRequest ¶
type SQLRequest struct {
// in: query
Device int `query:"device,optional" json:"device"`
// in: query
Verbose int `query:"verbose,optional" json:"verbose"`
// in: query
Debug int `query:"debug,optional" json:"debug"`
// in: query
Profiling string `query:"profiling,optional" json:"profiling"`
// in: query
DeviceChoosingTimeout int `query:"timeout,optional" json:"timeout"`
// in: header
Accept string `header:"Accept,optional" json:"accept"`
// in: header
Origin string `header:"Rpc-Caller,optional" json:"origin"`
// in: body
Body struct {
Queries []string `json:"queries"`
} `body:""`
}
SQLRequest represents SQL query request. Debug mode will run **each batch** in synchronized mode and report time for each step. swagger:parameters querySQL
type StringArrayResponse ¶
type StringArrayResponse struct {
//in: body
Body []string
}
StringArrayResponse represents string array response. swagger:response stringArrayResponse
func NewStringArrayResponse ¶
func NewStringArrayResponse() StringArrayResponse
NewStringArrayResponse creates a StringArrayResponse.