router

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteHeaderPrefix     = "HTTP_HEADER_"
	RouteParamPrefix      = "HTTP_PARAM_"
	RouteRequestKeyHeader = "HTTP_HEADER_X_REQUEST_KEY"
)

Variables

View Source
var ErrorRouteGettingRequestBody = errors.New("route getting request body")
View Source
var ErrorRouteMappingRequestBody = errors.New("route mapping request body")
View Source
var ErrorRouteParsingRequestBody = errors.New("route parsing request body")
View Source
var ErrorRouteProducingMessage = errors.New("route producing message")
View Source
var ErrorRouteReadingRequestBody = errors.New("route reading request body")
View Source
var ErrorWriteJsonFormat = errors.New("write json formatting")

Functions

func RouteProduceBodyMapConvert added in v0.0.11

func RouteProduceBodyMapConvert[Req any, Key any, Value any](
	source stateless.OneToOneFunction[message.Bytes, Req, Key, Value],
	requestFormat format.Format[Req],
	keyFormat format.Format[Key],
	valueFormat format.Format[Value],
) stateless.OneToOneFunction[message.Bytes, message.Bytes, message.Bytes, message.Bytes]

func RouteProduceTopicBodyMapConvert added in v0.0.16

func RouteProduceTopicBodyMapConvert[Req any, Key any, Value any](
	source stateless.OneToOneFunction[message.Bytes, Req, Key, Value],
	requestFormat format.Format[Req],
	produceTopic topic.Topic[Key, Value],
) stateless.OneToOneFunction[message.Bytes, message.Bytes, message.Bytes, message.Bytes]

func WithFlow added in v0.0.17

func WithFlow(input []FlowEntryTopic, output []FlowEntryTopic, stateTable string) runtime.Configuration[*RouteFlow]

configurations

func WithFlowMaterialiseOneToOne added in v0.0.17

func WithFlowMaterialiseOneToOne[
	IK any,
	IV any,
](
	input topic.Topic[IK, IV],
) runtime.Configuration[*RouteFlow]

func WithFlowStatefulOneToOne added in v0.0.17

func WithFlowStatefulOneToOne[
	IK any,
	IV any,
	OK any,
	OV any,
](
	input topic.Topic[IK, IV],
	output topic.Topic[OK, OV],
	stateTable string,
) runtime.Configuration[*RouteFlow]

func WithFlowStatefulOneToTwo added in v0.0.17

func WithFlowStatefulOneToTwo[
	IK any,
	IV any,
	OK1 any,
	OV1 any,
	OK2 any,
	OV2 any,
](
	input topic.Topic[IK, IV],
	output1 topic.Topic[OK1, OV1],
	output2 topic.Topic[OK2, OV2],
	stateTable string,
) runtime.Configuration[*RouteFlow]

func WithFlowStatelessOneToOne added in v0.0.17

func WithFlowStatelessOneToOne[
	IK any,
	IV any,
	OK any,
	OV any,
](
	input topic.Topic[IK, IV],
	output topic.Topic[OK, OV],
) runtime.Configuration[*RouteFlow]

func WithFlowStatelessOneToTwo added in v0.0.17

func WithFlowStatelessOneToTwo[
	IK any,
	IV any,
	OK1 any,
	OV1 any,
	OK2 any,
	OV2 any,
](
	input topic.Topic[IK, IV],
	output1 topic.Topic[OK1, OV1],
	output2 topic.Topic[OK2, OV2],
) runtime.Configuration[*RouteFlow]

func WithRouteProducerRuntime added in v0.0.4

func WithRouteProducerRuntime(producer message.Producer) runtime.Configuration[*RouteProducer]

configurations

func WriteError

func WriteError(w http.ResponseWriter, httpStatus int, err error) error

func WriteJson

func WriteJson[R any](w http.ResponseWriter, httpStatus int, r R, f format.Format[R]) error

Types

type BasicResponse added in v0.0.4

type BasicResponse struct {
	Message string `json:"message"`
}

route

type FlowEntries added in v0.0.17

type FlowEntries struct {
	Entries []FlowEntry `json:"entries"`
}

type FlowEntry added in v0.0.17

type FlowEntry struct {
	Input      []FlowEntryTopic `json:"inputs"`
	Output     []FlowEntryTopic `json:"outputs"`
	StateTable string           `json:"state_table"`
}

type FlowEntryTopic added in v0.0.17

type FlowEntryTopic struct {
	Topic     string `json:"topic"`
	KeyType   string `json:"key_type"`
	ValueType string `json:"value_type"`
}

implementation

func FlowEntryFromTopic added in v0.0.17

func FlowEntryFromTopic[IK any, IV any](topic topic.Topic[IK, IV]) FlowEntryTopic

type RouteFlow added in v0.0.17

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

func NewRouteFlow added in v0.0.17

func NewRouteFlow(configurations ...runtime.Configuration[*RouteFlow]) *RouteFlow

constructor

func (*RouteFlow) Handle added in v0.0.17

func (rp *RouteFlow) Handle(w http.ResponseWriter, req *http.Request)

type RouteProducer added in v0.0.4

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

implementation

func NewRouteProducer added in v0.0.4

func NewRouteProducer(configurations ...runtime.Configuration[*RouteProducer]) *RouteProducer

constructor

func (*RouteProducer) Handle added in v0.0.4

func (rp *RouteProducer) Handle(w http.ResponseWriter, req *http.Request)

func (*RouteProducer) Produce added in v0.0.4

func (rp *RouteProducer) Produce(w http.ResponseWriter, req *http.Request) error

Jump to

Keyboard shortcuts

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