Documentation ¶
Overview ¶
- @Author: Daniel TAN
- @Description:
- @Date: 2021-08-06 09:15:58
- @LastEditTime: 2021-09-07 10:46:38
- @LastEditors: Please set LastEditors
- @FilePath: /fr-price-common-pkg/core/httpx/parse.go
Author: Daniel TAN Date: 2021-09-05 10:24:33 LastEditors: Daniel TAN LastEditTime: 2021-10-03 14:56:13 FilePath: /trinity-micro/core/httpx/response.go Description:
Index ¶
- Constants
- func DIParamHandler(handler interface{}) func(w http.ResponseWriter, r *http.Request)
- func GetHTTPStatusCode(ctx context.Context, defaultStatus int) int
- func GetRawRequest(ctx context.Context) *http.Request
- func HandlerNumsIn(handlerType reflect.Type) int
- func HttpResponse(ctx context.Context, w http.ResponseWriter, status int, res interface{})
- func HttpResponseErr(ctx context.Context, w http.ResponseWriter, err error)
- func InvokeHandler(handlerType reflect.Type, r *http.Request) ([]reflect.Value, error)
- func InvokeMethod(handlerType reflect.Type, r *http.Request, instance interface{}, ...) ([]reflect.Value, error)
- func IsHandler(handlerType reflect.Type) bool
- func JsonResponse(w http.ResponseWriter, status int, res interface{})
- func NewWriter() http.ResponseWriter
- func Parse(r *http.Request, v interface{}) error
- func SetHeaderParser(h HeaderParser)
- func SetHttpStatusCode(ctx context.Context, status int)
- func SetQueryParser(h QueryParser)
- func XMLResponse(w http.ResponseWriter, status int, res interface{})
- type Context
- type DefaultHeaderParser
- type DefaultQueryParser
- type ErrorInfo
- type ErrorResponse
- type HTTPContextKey
- type HeaderParser
- type PaginationDTO
- type QueryParser
- type SuccessResponse
Constants ¶
View Source
const ( ContentDispositionHeader = "Content-Disposition" ContentLengthHeader = "Content-Length" ContentTypeHeader = "Content-Type" AcceptRangesHeader = "Accept-Ranges" ContentRangeHeader = "Content-Range" LastModifiedHeader = "Last-Modified" DispositionFormat = "attachment; filename=%s" )
View Source
const ( DefaultHttpErrorCode int = 400 DefaultHttpSuccessCode int = 200 )
Variables ¶
This section is empty.
Functions ¶
func DIParamHandler ¶
func DIParamHandler(handler interface{}) func(w http.ResponseWriter, r *http.Request)
func HandlerNumsIn ¶
func HttpResponse ¶
func HttpResponse(ctx context.Context, w http.ResponseWriter, status int, res interface{})
func HttpResponseErr ¶
func HttpResponseErr(ctx context.Context, w http.ResponseWriter, err error)
func InvokeHandler ¶
func InvokeMethod ¶
func JsonResponse ¶
func JsonResponse(w http.ResponseWriter, status int, res interface{})
func NewWriter ¶
func NewWriter() http.ResponseWriter
func SetHeaderParser ¶ added in v0.1.12
func SetHeaderParser(h HeaderParser)
func SetHttpStatusCode ¶
func SetQueryParser ¶ added in v0.1.12
func SetQueryParser(h QueryParser)
func XMLResponse ¶
func XMLResponse(w http.ResponseWriter, status int, res interface{})
Types ¶
type DefaultHeaderParser ¶ added in v0.1.12
type DefaultHeaderParser struct { }
type DefaultQueryParser ¶ added in v0.1.12
type DefaultQueryParser struct { }
type ErrorResponse ¶ added in v0.1.14
type HTTPContextKey ¶
type HTTPContextKey string
const (
HttpxContext HTTPContextKey = "HTTPX_CONTEXT_KEY"
)
type HeaderParser ¶ added in v0.1.12
type PaginationDTO ¶ added in v0.1.14
type PaginationDTO struct { Total int64 `json:"total" example:"120"` Current int `json:"current" example:"3"` TotalPage int `json:"total_page" example:"6"` PageSize int `json:"page_size" example:"20"` }
func NewPaginationDTO ¶ added in v0.1.14
func NewPaginationDTO(pageSize, pageNum int, total int64) *PaginationDTO
type QueryParser ¶ added in v0.1.12
type SuccessResponse ¶ added in v0.1.14
Click to show internal directories.
Click to hide internal directories.