transport_http

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContextKeyServerName = uuid.New().String()
	ContextKeyRequest    = uuid.New().String()
	ContextKeyOperators  = uuid.New().String()
)
View Source
var ProjectRef = os.Getenv("PROJECT_REF")
View Source
var RxHttpRouterPath = regexp.MustCompile("/:([^/]+)")

Functions

func ContextWithOperators

func ContextWithOperators(ctx context.Context, ops ...courier.IOperator) context.Context

func ContextWithRequest

func ContextWithRequest(ctx context.Context, req *http.Request) context.Context

func ContextWithServiceName

func ContextWithServiceName(ctx context.Context, serverName string) context.Context

func CreateHttpHandler

func CreateHttpHandler(s *ServeHTTP, ops ...courier.IOperator) httprouter.Handle

func GetClientIP

func GetClientIP(r *http.Request) string

func GetLongConnClient

func GetLongConnClient(timeout time.Duration) *http.Client

func GetOperators

func GetOperators(ctx context.Context) []courier.IOperator

func GetParams

func GetParams(path string, url string) (params httprouter.Params, err error)

func GetRequest

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

func GetShortConnClient

func GetShortConnClient(timeout time.Duration) *http.Client

func HttpStatusOK

func HttpStatusOK(code int) bool

func MarshalOperator

func MarshalOperator(r *http.Request, operator courier.IOperator) (err error)

func PayloadMarshal

func PayloadMarshal(payload interface{}) ([]byte, error)

func PayloadUnmarshal

func PayloadUnmarshal(data []byte, payload interface{}) error

Types

type BasePathDescriber

type BasePathDescriber interface {
	BasePath() string
}

type Binary

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

swagger:strfmt binary

func NewBinary

func NewBinary() *Binary

func (*Binary) Read

func (binary *Binary) Read(p []byte) (n int, err error)

func (*Binary) Write

func (binary *Binary) Write(p []byte) (n int, err error)

type File

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

swagger:strfmt binary

func NewFile

func NewFile(filename string, contentType string) *File

func (*File) ContentType

func (file *File) ContentType() string

func (*File) Meta

func (file *File) Meta() courier.Metadata

func (*File) Read

func (file *File) Read(p []byte) (n int, err error)

func (*File) Write

func (file *File) Write(p []byte) (n int, err error)

type HttpRequest

type HttpRequest struct {
	BaseURL       string
	Method        string
	URI           string
	ID            string
	Metadata      courier.Metadata
	Timeout       time.Duration
	Req           interface{}
	WrapTransport TransportWrapper
}

func (*HttpRequest) Do

func (httpRequest *HttpRequest) Do() (result courier.Result)

type HttpRouteMeta

type HttpRouteMeta struct {
	Route                         *courier.Route
	OperatorFactoryWithRouteMetas []*OperatorFactoryWithRouteMeta
}

func NewHttpRouteMeta

func NewHttpRouteMeta(route *courier.Route) *HttpRouteMeta

func (*HttpRouteMeta) Key

func (route *HttpRouteMeta) Key() string

func (*HttpRouteMeta) Log

func (route *HttpRouteMeta) Log()

func (*HttpRouteMeta) Method

func (route *HttpRouteMeta) Method() string

func (*HttpRouteMeta) OperatorNames

func (route *HttpRouteMeta) OperatorNames() string

func (*HttpRouteMeta) Path

func (route *HttpRouteMeta) Path() string

func (*HttpRouteMeta) String

func (route *HttpRouteMeta) String() string

type IBytesGetter

type IBytesGetter interface {
	Bytes() []byte
}

type IContentType

type IContentType interface {
	ContentType() string
}

type IHttpRequestTransformer

type IHttpRequestTransformer interface {
	TransformHttpRequest(req *http.Request)
}

type IMethod

type IMethod interface {
	Method() string
}

type IPath

type IPath interface {
	Path() string
}

type IStatus

type IStatus interface {
	Status() int
}

type IWebSocket

type IWebSocket interface {
	SubscribeOn(conn *websocket.Conn)
}

type Listener

type Listener func(v interface{}, ws *WSClient) error

type Listeners

type Listeners map[string]TypeAndListener

func (Listeners) On

func (listeners Listeners) On(v interface{}, listener Listener) Listeners

func (Listeners) SubscribeOn

func (listeners Listeners) SubscribeOn(conn *websocket.Conn)

type MetaOperator

type MetaOperator struct {
	courier.EmptyOperator
	// contains filtered or unexported fields
}

func BasePath

func BasePath(basePath string) *MetaOperator

func Group

func Group(path string) *MetaOperator

func (*MetaOperator) BasePath

func (g *MetaOperator) BasePath() string

func (*MetaOperator) Path

func (g *MetaOperator) Path() string

type MethodDescriber

type MethodDescriber interface {
	Method() string
}

type Msg

type Msg struct {
	Type    string `json:"type"`
	Payload []byte `json:"payload"`
}

type OperatorFactoryWithRouteMeta

type OperatorFactoryWithRouteMeta struct {
	*courier.OperatorFactory
	RouteMeta
}

func NewOperatorFactoryWithRouteMeta

func NewOperatorFactoryWithRouteMeta(op courier.IOperator, last bool) *OperatorFactoryWithRouteMeta

type ParameterValuesGetter

type ParameterValuesGetter struct {
	*transform.ParameterValuesGetter
	Params *httprouter.Params
}

func (*ParameterValuesGetter) Param

func (getter *ParameterValuesGetter) Param(name string) string

type PathDescriber

type PathDescriber interface {
	Path() string
}

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	Code int
	// contains filtered or unexported fields
}

func (*ResponseWriter) Hijack

func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(p []byte) (int, error)

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(code int)

type RouteMeta

type RouteMeta struct {
	ID         string
	Method     string
	Path       string
	BasePath   string
	Summary    string
	Deprecated bool
}

type ServeHTTP

type ServeHTTP struct {
	Name         string
	IP           string
	Port         int
	WriteTimeout envconfig.Duration
	ReadTimeout  envconfig.Duration
	WithCORS     bool
	// contains filtered or unexported fields
}

func (ServeHTTP) MarshalDefaults

func (s ServeHTTP) MarshalDefaults(v interface{})

func (*ServeHTTP) Serve

func (s *ServeHTTP) Serve(router *courier.Router) error

func (*ServeHTTP) ServeHTTP

func (s *ServeHTTP) ServeHTTP(w http.ResponseWriter, req *http.Request)

type TransportWrapper

type TransportWrapper func(rt http.RoundTripper) http.RoundTripper

type TypeAndListener

type TypeAndListener struct {
	Listener Listener
	Type     reflect.Type
}

type WSClient

type WSClient struct {
	Closed bool
	// contains filtered or unexported fields
}

func ConnWS

func ConnWS(conn *websocket.Conn) *WSClient

func (*WSClient) Close

func (c *WSClient) Close() error

func (WSClient) Send

func (c WSClient) Send(payload interface{}) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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