server

package
v0.0.0-...-009529a Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Each = "$each"
View Source
const Field = "$field"
View Source
const To = "$to"

Variables

This section is empty.

Functions

func NewServer

func NewServer(
	cfg config.Config,
	mapper mapping.Mapper,
	matchBuilder MatchBuilder,
	responseBuilder ResponseBuilder,
	appCtx context.Context,
) http.Handler

Types

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type MatchBuilder

type MatchBuilder func(request *http.Request, flow *mapping.Flow, body map[string]any) Matcher
var RequestMatchBuilder MatchBuilder = func(request *http.Request, flow *mapping.Flow, body map[string]any) Matcher {
	return &RequestMatcher{request: request, flow: flow, body: body}
}

type Matcher

type Matcher interface {
	Match()
	IsMatch() bool
}

type RequestMatcher

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

func (*RequestMatcher) IsMatch

func (m *RequestMatcher) IsMatch() bool

func (*RequestMatcher) Match

func (m *RequestMatcher) Match()

type RequestResponder

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

func (RequestResponder) Respond

func (r RequestResponder) Respond()

type Responder

type Responder interface {
	Respond()
}

type ResponseBuilder

type ResponseBuilder func(
	request *http.Request,
	flow *mapping.Flow,
	body map[string]any,
	rw http.ResponseWriter,
	mainCtx context.Context,
	client HTTPClient,
) Responder
var RequestResponseBuilder ResponseBuilder = func(
	request *http.Request,
	flow *mapping.Flow,
	body map[string]any,
	rw http.ResponseWriter,
	mainCtx context.Context,
	httpClient HTTPClient,
) Responder {
	return RequestResponder{
		request:    request,
		flow:       flow,
		body:       body,
		rw:         rw,
		mainCtx:    mainCtx,
		httpClient: httpClient,
		replacer:   replacer.NewReplacer(body, request.Header),
	}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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