Documentation
¶
Overview ¶
@Author: Daniel TAN
@Description:
@Date: 2021-08-06 11:05:44
@LastEditTime: 2021-08-06 11:06:21
@LastEditors: Daniel TAN
@FilePath: /fr-price-common-pkg/core/httpx/http_header_consts.go
@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-09-27 23:10:17 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(w http.ResponseWriter, status int, res interface{})
- func HttpResponseErr(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 SetHttpStatusCode(ctx context.Context, status int)
- func XMLResponse(w http.ResponseWriter, status int, res interface{})
- type HTTPContextKey
- type Response
- type ResponseError
Constants ¶
View Source
const ( ContentDispositionHeader = "Content-Disposition" ContentLengthHeader = "Content-Length" 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(w http.ResponseWriter, status int, res interface{})
func HttpResponseErr ¶
func HttpResponseErr(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 SetHttpStatusCode ¶
func XMLResponse ¶
func XMLResponse(w http.ResponseWriter, status int, res interface{})
Types ¶
type HTTPContextKey ¶
type HTTPContextKey string
const ( HTTPStatus HTTPContextKey = "HTTP_STATUS_CONTEXT_KEY" HTTPRequest HTTPContextKey = "HTTP_REQUEST_CONTEXT_KEY" )
type Response ¶
type Response struct {
Status int `json:"status"`
Result interface{} `json:"result,omitempty"`
Error *ResponseError `json:"error,omitempty"`
TraceID string `json:"trace_id"`
}
type ResponseError ¶
Click to show internal directories.
Click to hide internal directories.