httpx

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2021 License: MIT Imports: 11 Imported by: 0

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-10-03 14:56:13 FilePath: /trinity-micro/core/httpx/response.go Description:

Index

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 GetHTTPStatusCode

func GetHTTPStatusCode(ctx context.Context, defaultStatus int) int

func GetRawRequest

func GetRawRequest(ctx context.Context) *http.Request

func HandlerNumsIn

func HandlerNumsIn(handlerType reflect.Type) int

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 InvokeHandler(handlerType reflect.Type, r *http.Request) ([]reflect.Value, error)

func InvokeMethod

func InvokeMethod(handlerType reflect.Type, r *http.Request, instance interface{}, w http.ResponseWriter) ([]reflect.Value, error)

func IsHandler

func IsHandler(handlerType reflect.Type) bool

func JsonResponse

func JsonResponse(w http.ResponseWriter, status int, res interface{})

func NewWriter

func NewWriter() http.ResponseWriter

func Parse

func Parse(r *http.Request, v interface{}) error

func SetHttpStatusCode

func SetHttpStatusCode(ctx context.Context, status int)

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

type ResponseError struct {
	Code    int      `json:"code"`
	Message string   `json:"message"`
	Details []string `json:"details"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL