Documentation ¶
Index ¶
- Variables
- func ExchangeIpFromProxy(addr string, r contracts.RequestContract) string
- func GetJsonValue(r contracts.RequestContract, key string) []byte
- func JsonResponse(data interface{}, code int, headers map[string]string) contracts.ResponseContract
- func NetHeaderToString(h http.Header) string
- func Redirect(r contracts.RequestContract, url string, code int) contracts.ResponseContract
- func SetTrustedProxies(proxies ...string)
- func SetTrustedProxyHeaderSets(sets ...string)
- type ApiResouce
- func (ar *ApiResouce) Code(code int) *ApiResouce
- func (ar *ApiResouce) Data(data interface{}) *ApiResouce
- func (ar *ApiResouce) MarshalJSON() ([]byte, error)
- func (ar *ApiResouce) Message(message string) *ApiResouce
- func (ar *ApiResouce) StatusCode() int
- func (ar *ApiResouce) WithStatus(statusCode int) *ApiResouce
- type ErrorResponse
- func ErrResponse(e exception.Exception, code int, headers map[string]string) *ErrorResponse
- func ErrResponseFromError(e error, code int, headers map[string]string) *ErrorResponse
- func ErrResponseFromOrigin(resp *Response) *ErrorResponse
- func HttpErrorResponse(message string, statusCode int, code int, headers map[string]string) *ErrorResponse
- func NotFoundResponse(message string) *ErrorResponse
- type FastHttpFileServer
- type FastHttpRequest
- func (r *FastHttpRequest) Accepts() []byte
- func (r *FastHttpRequest) Authorization() []byte
- func (r *FastHttpRequest) BearerToken() ([]byte, error)
- func (r *FastHttpRequest) Context() context.Context
- func (r *FastHttpRequest) CookieByte(key string) []byte
- func (r *FastHttpRequest) ExceptsJson() bool
- func (r *FastHttpRequest) File(key string) (contracts.UploadFile, error)
- func (r *FastHttpRequest) Get(key string) []byte
- func (r *FastHttpRequest) GetClientIp() string
- func (r *FastHttpRequest) GetContent() []byte
- func (r *FastHttpRequest) GetInt(key string) (int, error)
- func (r *FastHttpRequest) GetInt64(key string) (int64, error)
- func (r *FastHttpRequest) GetMethod() string
- func (r *FastHttpRequest) GetPathBytes() []byte
- func (r *FastHttpRequest) GetSignature() []byte
- func (r *FastHttpRequest) GetString(key string) string
- func (r FastHttpRequest) GetURL() *url.URL
- func (r *FastHttpRequest) GetUint64(key string) (uint64, error)
- func (r *FastHttpRequest) GetUri() []byte
- func (r *FastHttpRequest) GetValue(key ...string) contracts.InputValue
- func (r *FastHttpRequest) Header(key string) []byte
- func (r *FastHttpRequest) HeaderString(key string) string
- func (r *FastHttpRequest) IsXmlHttpRequest() bool
- func (r *FastHttpRequest) Origin() *fasthttp.RequestCtx
- func (f *FastHttpRequest) RemoteAddr() string
- func (r *FastHttpRequest) RequestWithJson() bool
- func (r *FastHttpRequest) SetHeader(key string, value []byte) contracts.RequestContract
- func (r *FastHttpRequest) SetHeaderString(key, value string) contracts.RequestContract
- func (r *FastHttpRequest) ToString() string
- func (r *FastHttpRequest) Unmarshal(to interface{}) error
- type File
- type JsonInput
- type JsonInputHandler
- type JsonMessage
- type JsonRequest
- type MapInput
- type NetHttpRequest
- func (n *NetHttpRequest) Accepts() []byte
- func (n *NetHttpRequest) Authorization() []byte
- func (n *NetHttpRequest) BearerToken() ([]byte, error)
- func (n *NetHttpRequest) Context() context.Context
- func (n *NetHttpRequest) CookieByte(key string) []byte
- func (n *NetHttpRequest) ExceptsJson() bool
- func (n *NetHttpRequest) File(key string) (contracts.UploadFile, error)
- func (n *NetHttpRequest) Get(key string) []byte
- func (n *NetHttpRequest) GetClientIp() string
- func (n *NetHttpRequest) GetContent() []byte
- func (n *NetHttpRequest) GetInt(key string) (int, error)
- func (n *NetHttpRequest) GetInt64(key string) (int64, error)
- func (n *NetHttpRequest) GetMethod() string
- func (n *NetHttpRequest) GetPathBytes() []byte
- func (n *NetHttpRequest) GetSignature() []byte
- func (n *NetHttpRequest) GetString(key string) string
- func (n *NetHttpRequest) GetURL() *url.URL
- func (n *NetHttpRequest) GetUint64(key string) (uint64, error)
- func (n *NetHttpRequest) GetUri() []byte
- func (n *NetHttpRequest) GetValue(key ...string) contracts.InputValue
- func (n *NetHttpRequest) Header(key string) []byte
- func (n *NetHttpRequest) HeaderString(key string) string
- func (n *NetHttpRequest) IsXmlHttpRequest() bool
- func (n *NetHttpRequest) Origin() *http.Request
- func (n *NetHttpRequest) OriginWriter() http.ResponseWriter
- func (n *NetHttpRequest) RemoteAddr() string
- func (n *NetHttpRequest) RequestWithJson() bool
- func (n *NetHttpRequest) SetHeader(key string, value []byte) contracts.RequestContract
- func (n *NetHttpRequest) SetHeaderString(key, value string) contracts.RequestContract
- func (n *NetHttpRequest) ToString() string
- func (n *NetHttpRequest) Unmarshal(to interface{}) error
- type Param
- type ParamInt
- type ParamInt64
- type ParamUint64
- type RedirectResponse
- type Request
- type Response
- func (r *Response) ClearCookies()
- func (r *Response) Content() []byte
- func (r *Response) Cookies() []*http.Cookie
- func (r *Response) Handled() bool
- func (r *Response) Header(header string) string
- func (r *Response) Headers() map[string]string
- func (r *Response) SetCookie(cookie *http.Cookie)
- func (r *Response) SetHeader(key string, value string) contracts.ResponseContract
- func (r *Response) SetHeaders(headers map[string]string) contracts.ResponseContract
- func (r *Response) SetStatusCode(code int) contracts.ResponseContract
- func (r *Response) StatusCode() int
- type SimpleParamRequest
- func (shr *SimpleParamRequest) GetContainer() container.Interface
- func (shr *SimpleParamRequest) GetRouteName() string
- func (shr *SimpleParamRequest) Param(key string) string
- func (shr *SimpleParamRequest) ParamBytes(key string) []byte
- func (shr *SimpleParamRequest) ParamInt(key string) (int, error)
- func (shr *SimpleParamRequest) ParamInt64(key string) (int64, error)
- func (shr *SimpleParamRequest) ParamUint64(key string) (uint64, error)
- func (shr *SimpleParamRequest) Params() map[string][]byte
- func (shr *SimpleParamRequest) ParamsSlice() [][]byte
- func (shr *SimpleParamRequest) SetContainer(ioc container.Interface)
- func (shr *SimpleParamRequest) SetParams(params map[string][]byte)
- func (shr *SimpleParamRequest) SetParamsSlice(paramsSlice [][]byte)
- func (shr *SimpleParamRequest) SetRouteName(name string)
- type StreamResponse
- type TemplateResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultDataKey = "data" DefaultCodeKey = "code" DefaultMessageKey = "message" DefaultCode = 200 )
View Source
var ( ContentTypeJson = "application/json; charset=utf-8" ContentTypeHtml = "text/html; charset=utf-8" DefaultHeader = func() map[string]string { return map[string]string{} } TextHeader = func() map[string]string { return map[string]string{ "Content-Type": ContentTypeHtml, } } JsonHeader = func() map[string]string { return map[string]string{ "Content-Type": ContentTypeJson, } } HtmlHeader = func() map[string]string { return map[string]string{ "Content-Type": ContentTypeHtml, } } )
View Source
var (
ErrInvalidRequest = errors.New("invalid request")
)
Functions ¶
func ExchangeIpFromProxy ¶ added in v1.1.0
func ExchangeIpFromProxy(addr string, r contracts.RequestContract) string
func GetJsonValue ¶
func GetJsonValue(r contracts.RequestContract, key string) []byte
func JsonResponse ¶
func JsonResponse(data interface{}, code int, headers map[string]string) contracts.ResponseContract
func NetHeaderToString ¶
func Redirect ¶ added in v1.1.1
func Redirect(r contracts.RequestContract, url string, code int) contracts.ResponseContract
func SetTrustedProxies ¶ added in v1.1.0
func SetTrustedProxies(proxies ...string)
func SetTrustedProxyHeaderSets ¶ added in v1.1.0
func SetTrustedProxyHeaderSets(sets ...string)
Types ¶
type ApiResouce ¶
type ApiResouce struct {
// contains filtered or unexported fields
}
func ResourceResponse ¶
func ResourceResponse(data interface{}) *ApiResouce
func (*ApiResouce) Code ¶
func (ar *ApiResouce) Code(code int) *ApiResouce
func (*ApiResouce) Data ¶
func (ar *ApiResouce) Data(data interface{}) *ApiResouce
func (*ApiResouce) MarshalJSON ¶
func (ar *ApiResouce) MarshalJSON() ([]byte, error)
func (*ApiResouce) Message ¶
func (ar *ApiResouce) Message(message string) *ApiResouce
func (*ApiResouce) StatusCode ¶ added in v0.0.17
func (ar *ApiResouce) StatusCode() int
func (*ApiResouce) WithStatus ¶ added in v0.0.17
func (ar *ApiResouce) WithStatus(statusCode int) *ApiResouce
type ErrorResponse ¶
type ErrorResponse struct { *Response // contains filtered or unexported fields }
func ErrResponse ¶
func ErrResponseFromError ¶
func ErrResponseFromError(e error, code int, headers map[string]string) *ErrorResponse
func ErrResponseFromOrigin ¶
func ErrResponseFromOrigin(resp *Response) *ErrorResponse
func HttpErrorResponse ¶
func NotFoundResponse ¶
func NotFoundResponse(message string) *ErrorResponse
func (*ErrorResponse) E ¶
func (e *ErrorResponse) E() exception.Exception
type FastHttpFileServer ¶
type FastHttpFileServer struct { *Response // contains filtered or unexported fields }
func NewFastHttpFileServer ¶
func NewFastHttpFileServer(root string, stripSlashes int) *FastHttpFileServer
func (*FastHttpFileServer) Root ¶
func (ffs *FastHttpFileServer) Root() string
func (*FastHttpFileServer) StripSlashes ¶
func (ffs *FastHttpFileServer) StripSlashes() int
type FastHttpRequest ¶
type FastHttpRequest struct { SimpleParamRequest // contains filtered or unexported fields }
func NewFastHttpRequest ¶
func NewFastHttpRequest(origin *fasthttp.RequestCtx) *FastHttpRequest
func (*FastHttpRequest) Accepts ¶
func (r *FastHttpRequest) Accepts() []byte
func (*FastHttpRequest) Authorization ¶
func (r *FastHttpRequest) Authorization() []byte
func (*FastHttpRequest) BearerToken ¶
func (r *FastHttpRequest) BearerToken() ([]byte, error)
func (*FastHttpRequest) Context ¶
func (r *FastHttpRequest) Context() context.Context
func (*FastHttpRequest) CookieByte ¶ added in v1.1.3
func (r *FastHttpRequest) CookieByte(key string) []byte
func (*FastHttpRequest) ExceptsJson ¶
func (r *FastHttpRequest) ExceptsJson() bool
func (*FastHttpRequest) File ¶
func (r *FastHttpRequest) File(key string) (contracts.UploadFile, error)
func (*FastHttpRequest) Get ¶
func (r *FastHttpRequest) Get(key string) []byte
func (*FastHttpRequest) GetClientIp ¶
func (r *FastHttpRequest) GetClientIp() string
func (*FastHttpRequest) GetContent ¶
func (r *FastHttpRequest) GetContent() []byte
func (*FastHttpRequest) GetMethod ¶
func (r *FastHttpRequest) GetMethod() string
func (*FastHttpRequest) GetPathBytes ¶
func (r *FastHttpRequest) GetPathBytes() []byte
func (*FastHttpRequest) GetSignature ¶
func (r *FastHttpRequest) GetSignature() []byte
func (*FastHttpRequest) GetString ¶
func (r *FastHttpRequest) GetString(key string) string
func (FastHttpRequest) GetURL ¶ added in v1.1.2
func (r FastHttpRequest) GetURL() *url.URL
func (*FastHttpRequest) GetUri ¶
func (r *FastHttpRequest) GetUri() []byte
func (*FastHttpRequest) GetValue ¶
func (r *FastHttpRequest) GetValue(key ...string) contracts.InputValue
func (*FastHttpRequest) Header ¶
func (r *FastHttpRequest) Header(key string) []byte
func (*FastHttpRequest) HeaderString ¶
func (r *FastHttpRequest) HeaderString(key string) string
func (*FastHttpRequest) IsXmlHttpRequest ¶
func (r *FastHttpRequest) IsXmlHttpRequest() bool
func (*FastHttpRequest) Origin ¶
func (r *FastHttpRequest) Origin() *fasthttp.RequestCtx
func (*FastHttpRequest) RemoteAddr ¶ added in v0.0.14
func (f *FastHttpRequest) RemoteAddr() string
func (*FastHttpRequest) RequestWithJson ¶
func (r *FastHttpRequest) RequestWithJson() bool
func (*FastHttpRequest) SetHeader ¶
func (r *FastHttpRequest) SetHeader(key string, value []byte) contracts.RequestContract
func (*FastHttpRequest) SetHeaderString ¶
func (r *FastHttpRequest) SetHeaderString(key, value string) contracts.RequestContract
func (*FastHttpRequest) ToString ¶ added in v0.0.9
func (r *FastHttpRequest) ToString() string
func (*FastHttpRequest) Unmarshal ¶
func (r *FastHttpRequest) Unmarshal(to interface{}) error
type File ¶
type File struct { *Response // contains filtered or unexported fields }
func NewFileResponse ¶
type JsonInput ¶ added in v1.2.2
type JsonInput []byte
func (JsonInput) Each ¶ added in v1.2.2
func (j JsonInput) Each(h JsonInputHandler) error
func (JsonInput) File ¶ added in v1.2.2
func (j JsonInput) File(key string) (contracts.UploadFile, error)
func (JsonInput) GetValue ¶ added in v1.2.2
func (j JsonInput) GetValue(key ...string) contracts.InputValue
func (JsonInput) ParamBytes ¶ added in v1.2.2
type JsonInputHandler ¶ added in v1.2.2
type JsonMessage ¶
type JsonMessage int
func (JsonMessage) MarshalJSON ¶
func (m JsonMessage) MarshalJSON() ([]byte, error)
func (JsonMessage) StatusCode ¶ added in v0.0.7
func (m JsonMessage) StatusCode() int
type JsonRequest ¶ added in v1.2.4
type JsonRequest struct {
contracts.RequestContract
}
type MapInput ¶ added in v1.2.0
type MapInput struct {
// contains filtered or unexported fields
}
func (MapInput) MarshalJSON ¶ added in v1.2.0
type NetHttpRequest ¶
type NetHttpRequest struct { SimpleParamRequest // contains filtered or unexported fields }
func NewNetHttpRequest ¶
func NewNetHttpRequest(origin *http.Request, w http.ResponseWriter) *NetHttpRequest
func (*NetHttpRequest) Accepts ¶
func (n *NetHttpRequest) Accepts() []byte
func (*NetHttpRequest) Authorization ¶
func (n *NetHttpRequest) Authorization() []byte
func (*NetHttpRequest) BearerToken ¶
func (n *NetHttpRequest) BearerToken() ([]byte, error)
func (*NetHttpRequest) Context ¶
func (n *NetHttpRequest) Context() context.Context
func (*NetHttpRequest) CookieByte ¶ added in v1.1.3
func (n *NetHttpRequest) CookieByte(key string) []byte
func (*NetHttpRequest) ExceptsJson ¶
func (n *NetHttpRequest) ExceptsJson() bool
func (*NetHttpRequest) File ¶
func (n *NetHttpRequest) File(key string) (contracts.UploadFile, error)
func (*NetHttpRequest) Get ¶
func (n *NetHttpRequest) Get(key string) []byte
func (*NetHttpRequest) GetClientIp ¶
func (n *NetHttpRequest) GetClientIp() string
/ GetClientIp get client ip / reverse proxy need implement
func (*NetHttpRequest) GetContent ¶
func (n *NetHttpRequest) GetContent() []byte
func (*NetHttpRequest) GetMethod ¶
func (n *NetHttpRequest) GetMethod() string
func (*NetHttpRequest) GetPathBytes ¶
func (n *NetHttpRequest) GetPathBytes() []byte
func (*NetHttpRequest) GetSignature ¶
func (n *NetHttpRequest) GetSignature() []byte
func (*NetHttpRequest) GetString ¶
func (n *NetHttpRequest) GetString(key string) string
func (*NetHttpRequest) GetURL ¶ added in v1.1.2
func (n *NetHttpRequest) GetURL() *url.URL
func (*NetHttpRequest) GetUri ¶
func (n *NetHttpRequest) GetUri() []byte
func (*NetHttpRequest) GetValue ¶
func (n *NetHttpRequest) GetValue(key ...string) contracts.InputValue
func (*NetHttpRequest) Header ¶
func (n *NetHttpRequest) Header(key string) []byte
func (*NetHttpRequest) HeaderString ¶
func (n *NetHttpRequest) HeaderString(key string) string
func (*NetHttpRequest) IsXmlHttpRequest ¶
func (n *NetHttpRequest) IsXmlHttpRequest() bool
func (*NetHttpRequest) Origin ¶
func (n *NetHttpRequest) Origin() *http.Request
func (*NetHttpRequest) OriginWriter ¶
func (n *NetHttpRequest) OriginWriter() http.ResponseWriter
func (*NetHttpRequest) RemoteAddr ¶
func (n *NetHttpRequest) RemoteAddr() string
func (*NetHttpRequest) RequestWithJson ¶
func (n *NetHttpRequest) RequestWithJson() bool
func (*NetHttpRequest) SetHeader ¶
func (n *NetHttpRequest) SetHeader(key string, value []byte) contracts.RequestContract
func (*NetHttpRequest) SetHeaderString ¶
func (n *NetHttpRequest) SetHeaderString(key, value string) contracts.RequestContract
func (*NetHttpRequest) ToString ¶ added in v0.0.9
func (n *NetHttpRequest) ToString() string
func (*NetHttpRequest) Unmarshal ¶
func (n *NetHttpRequest) Unmarshal(to interface{}) error
type ParamUint64 ¶
type ParamUint64 uint64
func (ParamUint64) Value ¶
func (p ParamUint64) Value() uint64
type RedirectResponse ¶ added in v1.1.1
type RedirectResponse struct { *Response // contains filtered or unexported fields }
func (*RedirectResponse) URL ¶ added in v1.1.1
func (r *RedirectResponse) URL() string
type Request ¶
type Request struct {
contracts.RequestContract
}
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response http response
func HtmlResponse ¶
func NewHandledResponse ¶
func TextResponse ¶
func (*Response) ClearCookies ¶ added in v1.1.3
func (r *Response) ClearCookies()
func (*Response) SetHeader ¶
func (r *Response) SetHeader(key string, value string) contracts.ResponseContract
func (*Response) SetHeaders ¶ added in v0.0.7
func (r *Response) SetHeaders(headers map[string]string) contracts.ResponseContract
func (*Response) SetStatusCode ¶
func (r *Response) SetStatusCode(code int) contracts.ResponseContract
type SimpleParamRequest ¶
type SimpleParamRequest struct {
// contains filtered or unexported fields
}
func (*SimpleParamRequest) GetContainer ¶ added in v0.0.10
func (shr *SimpleParamRequest) GetContainer() container.Interface
func (*SimpleParamRequest) GetRouteName ¶ added in v1.0.0
func (shr *SimpleParamRequest) GetRouteName() string
func (*SimpleParamRequest) Param ¶
func (shr *SimpleParamRequest) Param(key string) string
func (*SimpleParamRequest) ParamBytes ¶
func (shr *SimpleParamRequest) ParamBytes(key string) []byte
func (*SimpleParamRequest) ParamInt ¶
func (shr *SimpleParamRequest) ParamInt(key string) (int, error)
func (*SimpleParamRequest) ParamInt64 ¶
func (shr *SimpleParamRequest) ParamInt64(key string) (int64, error)
func (*SimpleParamRequest) ParamUint64 ¶
func (shr *SimpleParamRequest) ParamUint64(key string) (uint64, error)
func (*SimpleParamRequest) Params ¶
func (shr *SimpleParamRequest) Params() map[string][]byte
func (*SimpleParamRequest) ParamsSlice ¶
func (shr *SimpleParamRequest) ParamsSlice() [][]byte
func (*SimpleParamRequest) SetContainer ¶ added in v0.0.10
func (shr *SimpleParamRequest) SetContainer(ioc container.Interface)
func (*SimpleParamRequest) SetParams ¶
func (shr *SimpleParamRequest) SetParams(params map[string][]byte)
func (*SimpleParamRequest) SetParamsSlice ¶
func (shr *SimpleParamRequest) SetParamsSlice(paramsSlice [][]byte)
func (*SimpleParamRequest) SetRouteName ¶ added in v1.0.0
func (shr *SimpleParamRequest) SetRouteName(name string)
type StreamResponse ¶ added in v1.1.10
type StreamResponse struct { *Response // contains filtered or unexported fields }
func NewDownloadResponse ¶ added in v1.1.10
func NewDownloadResponse(stream io.ReadCloser, filename string) *StreamResponse
func NewStreamResponse ¶ added in v1.1.10
func NewStreamResponse(stream io.ReadCloser, code int) *StreamResponse
func (*StreamResponse) Stream ¶ added in v1.1.10
func (sr *StreamResponse) Stream() io.ReadCloser
type TemplateResponse ¶
type TemplateResponse struct { *Response // contains filtered or unexported fields }
func TempResponse ¶
func TempResponse(t *template.Template, code int, data interface{}) *TemplateResponse
func (*TemplateResponse) SetTemplateData ¶
func (t *TemplateResponse) SetTemplateData(templateData interface{}) *TemplateResponse
func (*TemplateResponse) Template ¶
func (t *TemplateResponse) Template() *template.Template
func (*TemplateResponse) TemplateData ¶
func (t *TemplateResponse) TemplateData() interface{}
Click to show internal directories.
Click to hide internal directories.