http

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

HTTP Endpoint Service

Service Id Action Description Request Response
http/endpoint listen listen on specified port to replay recorded HTTP conversation ListenRequest ListenResponse

Documentation

Index

Constants

View Source
const (
	//URLKey represents url key
	URLKey = "URL"
	//CookieKey represents cookie header key
	CookieKey = "Cookie"
	//ContentTypeKey represents content type header key
	ContentTypeKey = "Content-Type"
	//MethodKey represents http method key
	MethodKey = "Method"
	//BodyKey represents http body key
	BodyKey = "Body"
)
View Source
const (
	//ServiceID represents hTTPEndpoint service id.
	ServiceID = "http/endpoint"
)

Variables

View Source
var HTTPRequestKeyProviders = make(map[string]HTTPRequestKeyProvider)

HTTPRequestKeyProviders represents key providers

Functions

func New

func New() endly.Service

New creates a new HTTP endpoint service, to replay previously recorded HTTP trips.

func StartServer

func StartServer(port int, trips *HTTPServerTrips) error

StartServer starts http request, the server has ability to replay recorded HTTP trips with https://github.com/viant/toolbox/blob/master/bridge/http_bridge_recording_util.go#L82

Types

type HTTPRequestKeyProvider

type HTTPRequestKeyProvider func(source interface{}) (string, error)

HTTPRequestKeyProvider represents request key provider to extract a request field.

func HeaderProvider

func HeaderProvider(header string) HTTPRequestKeyProvider

HeaderProvider return a header value for supplied source

type HTTPResponses

type HTTPResponses struct {
	Request   *bridge.HttpRequest
	Responses []*bridge.HttpResponse
	Index     int
}

HTTPResponses represents HTTPResponses

type HTTPServerTrips

type HTTPServerTrips struct {
	BaseDirectory string
	Trips         map[string]*HTTPResponses
	IndexKeys     []string
	Mutex         *sync.Mutex
}

HTTPServerTrips represents http trips

func (*HTTPServerTrips) Init

func (t *HTTPServerTrips) Init() error

Init initialises trips

type ListenRequest

type ListenRequest struct {
	Port          int
	BaseDirectory string   `` /* 164-byte string literal not displayed */
	IndexKeys     []string `description:"recorded requests matching keys, by default: Method,URL,Body,Cookie,Content-Type"`
}

ListenRequest represent HTTP endpoint listen request

func (ListenRequest) AsHTTPServerTrips

func (r ListenRequest) AsHTTPServerTrips() *HTTPServerTrips

AsHTTPServerTrips return a new HTTP trips.

func (ListenRequest) Validate

func (r ListenRequest) Validate() error

Validate checks if request is valid.

type ListenResponse

type ListenResponse struct {
	Trips map[string]*HTTPResponses
}

ListenResponse represents HTTP endpoint listen response with indexed trips

Jump to

Keyboard shortcuts

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