Documentation
¶
Index ¶
- Constants
- func BuildErrorResponse(err error) (statusCode int, errorMessage string)
- func Compress(reader io.Reader) (*bytes.Buffer, error)
- func WriteError(writer http.ResponseWriter, err error)
- type ClosableResponse
- type Error
- type Errors
- type HttpMessageError
- type Option
- type Request
- func (r *Request) Cookie(name string) *http.Cookie
- func (r *Request) HasCookie(name string) bool
- func (r *Request) HasPathVariable(name string) bool
- func (r *Request) HasQuery(name string) bool
- func (r *Request) Path() string
- func (r *Request) PathVariable(name string) string
- func (r *Request) QueryParam(name string) string
- func (r *Request) RelativePath() string
- type Violations
- func (v Violations) MergeCustom(custom map[string]interface{}) []*validator.Violation
- func (v Violations) MergeErrors(errors []*Error) []*validator.Violation
- func (v Violations) MergeGoViolation(violations []*govalidator.Violation) Violations
- func (v Violations) MergeSqlViolation(violations []*sqlxvalidator.Violation) []*validator.Violation
Constants ¶
View Source
const ( AllowOriginHeader = "Access-Control-Allow-Origin" AllowHeadersHeader = "Access-Control-Allow-Headers" AllowMethodsHeader = "Access-Control-Allow-Methods" AllControlRequestHeader = "Access-Control-Request-Method" AllowCredentialsHeader = "Access-Control-Allow-Credentials" ExposeHeadersHeader = "Access-Control-Expose-Headers" MaxAgeHeader = "Access-Control-Max-Age" DatlyRequestMetricsHeader = "Datly-Show-Metrics" DatlyInfoHeaderValue = "info" DatlyDebugHeaderValue = "debug" DatlyRequestDisableCacheHeader = "Datly-Disable-Cache" DatlyResponseHeaderMetrics = "Datly-Metrics" DatlyServiceTimeHeader = "Datly-Service-Time" DatlyServiceInitHeader = "Datly-Service-init" //ContentTypeJSON json content type ContentTypeJSON = "application/json" CharsetUTF8 = "charset=utf-8" //EncodingGzip encoding gzip EncodingGzip = "gzip" ContentLength = "Content-Length" )
Variables ¶
This section is empty.
Functions ¶
func BuildErrorResponse ¶
func WriteError ¶
func WriteError(writer http.ResponseWriter, err error)
Types ¶
type ClosableResponse ¶
type ClosableResponse struct { http.ResponseWriter Closed bool }
func NewClosableResponse ¶
func NewClosableResponse(response http.ResponseWriter) *ClosableResponse
func (*ClosableResponse) WriteHeader ¶
func (c *ClosableResponse) WriteHeader(statusCode int)
type Error ¶
type Error struct { View string `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` Parameter string `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` StatusCode int `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` Err error `json:"-"` Message string `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` Object interface{} `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` }
func NewParamError ¶
type Errors ¶
type Errors struct { Message string `json:",omitempty" default:"nullable=true,required=false,allowEmpty=true"` Errors []*Error // contains filtered or unexported fields }
func (*Errors) ErrorStatusCode ¶
type HttpMessageError ¶
type HttpMessageError struct {
// contains filtered or unexported fields
}
func ErrorOf ¶
func ErrorOf(defaultStatusCode int, err error) *HttpMessageError
func NewHttpMessageError ¶
func NewHttpMessageError(statusCode int, err error) *HttpMessageError
func NewHttpStatusError ¶
func NewHttpStatusError(statusCode int) *HttpMessageError
func (*HttpMessageError) Err ¶
func (h *HttpMessageError) Err() error
func (*HttpMessageError) Error ¶
func (h *HttpMessageError) Error() string
func (*HttpMessageError) ErrorMessage ¶
func (h *HttpMessageError) ErrorMessage() string
func (*HttpMessageError) ErrorStatusCode ¶
func (h *HttpMessageError) ErrorStatusCode() int
type Option ¶
type Option func(e *Error)
func WithMessage ¶
func WithObject ¶
func WithObject(object interface{}) Option
func WithStatusCode ¶
type Request ¶
type Request struct { Url string `velty:"-"` QueryParams url.Values `velty:"-"` PathVariables map[string]string `velty:"-"` Headers http.Header `velty:"-"` // contains filtered or unexported fields }
func NewRequest ¶
func (*Request) HasPathVariable ¶
func (*Request) PathVariable ¶
func (*Request) QueryParam ¶
func (*Request) RelativePath ¶
type Violations ¶
func (Violations) MergeCustom ¶
func (v Violations) MergeCustom(custom map[string]interface{}) []*validator.Violation
func (Violations) MergeErrors ¶
func (v Violations) MergeErrors(errors []*Error) []*validator.Violation
func (Violations) MergeGoViolation ¶
func (v Violations) MergeGoViolation(violations []*govalidator.Violation) Violations
func (Violations) MergeSqlViolation ¶
func (v Violations) MergeSqlViolation(violations []*sqlxvalidator.Violation) []*validator.Violation
Click to show internal directories.
Click to hide internal directories.