http

package
v0.0.0-...-b804f52 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MulanPSL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const SupportPackageIsVersion1 = true

SupportPackageIsVersion1 These constants should not be referenced from any other code.

Variables

This section is empty.

Functions

func Bind

func Bind(req *http.Request, target interface{}) error

func BindForm

func BindForm(req *http.Request, target interface{}) error

BindForm bind form parameters to target.

func BindQuery

func BindQuery(req *http.Request, target interface{}) error

BindQuery bind vars parameters to target.

func CodecForRequest

func CodecForRequest(r *http.Request, name string) (encoding.Codec, bool)

CodecForRequest get encoding.Codec via http.Request

func DefaultResponseEncoder

func DefaultResponseEncoder(w http.ResponseWriter, r *http.Request, v interface{}) error

DefaultResponseEncoder encodes the object to the HTTP response.

func EncodeResponse

func EncodeResponse(w http.ResponseWriter, r *http.Request, v interface{}) error

func ExcelResponse

func ExcelResponse(fileName string) func(context.Context, http.ResponseWriter, interface{}) error

func HttpClientFilter

func HttpClientFilter(mid []endpoint.Middleware) func(context.Context, *http.Request) context.Context

func HttpServerFilter

func HttpServerFilter() mux.MiddlewareFunc

func JSONResponse

func JSONResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)

func JSONiterResponse

func JSONiterResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)

func ReturnResponse

func ReturnResponse(code int, contentType string) func(context.Context, http.ResponseWriter, interface{}) error

func SetOperation

func SetOperation(ctx context.Context, op string)

SetOperation sets the transport operation.

func StringResponse

func StringResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)

func ToheaderCarrier

func ToheaderCarrier(h http.Header) headerCarrier

func XMLResponse

func XMLResponse(ctx context.Context, w http.ResponseWriter, response interface{}) (err error)

Types

type DecodeRequestFunc

type DecodeRequestFunc func(*http.Request, interface{}) error

DecodeRequestFunc is decode request func.

type EncodeErrorFunc

type EncodeErrorFunc func(http.ResponseWriter, *http.Request, error)

EncodeErrorFunc is encode error func.

type EncodeResponseFunc

type EncodeResponseFunc func(http.ResponseWriter, *http.Request, interface{}) error

EncodeResponseFunc is encode response func.

type Transport

type Transport struct {
	// contains filtered or unexported fields
}

Transport is an HTTP transport.

func NewTransport

func NewTransport(endpoint, operation, pathTemplate string, reqHeader, replyHeader headerCarrier, request *http.Request) *Transport

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

Endpoint returns the transport endpoint.

func (*Transport) Kind

func (tr *Transport) Kind() xtransport.Kind

Kind returns the transport kind.

func (*Transport) Operation

func (tr *Transport) Operation() string

Operation returns the transport operation.

func (*Transport) PathTemplate

func (tr *Transport) PathTemplate() string

PathTemplate returns the http path template.

func (*Transport) ReplyHeader

func (tr *Transport) ReplyHeader() xtransport.Header

ReplyHeader returns the reply header.

func (*Transport) Request

func (tr *Transport) Request() *http.Request

Request returns the HTTP request.

func (*Transport) RequestHeader

func (tr *Transport) RequestHeader() xtransport.Header

RequestHeader returns the request header.

type Transporter

type Transporter interface {
	xtransport.Transporter
	Request() *http.Request
	PathTemplate() string
}

Transporter is http Transporter

Jump to

Keyboard shortcuts

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