http

package
v0.0.0-...-cdef871 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStopIteration = errors.New("stop iteration")
	ErrNoSuchInput   = errors.New("no such input")
)
View Source
var ErrInvalidWebHookPayloadType = errors.New("invalid webhook payload type")
View Source
var ErrNoAPIKey = errors.New("No API key found in the request")

ErrNoAPIKey is when no API key is in the request

View Source
var ErrNotNow = errors.New("The actor is not ready, try again later")

ErrNotNow ...

View Source
var ErrTemporaryError = errors.New(
	"An error occurred that should not put the process in fail state")

ErrTemporaryError ...

Functions

func NewWebHookHandler

func NewWebHookHandler(actor *xbus.Actor) xbus.ActorService

NewWebHookHandler ...

func SetupCredentials

func SetupCredentials(options nats.Options, r *http.Request) (nats.Options, error)

SetupCredentials extract credentials from a request and inject them in a nats.Options

Types

type Credentials

type Credentials struct {
	APIKey   string
	User     string
	Password string
}

Credentials holds user credentials extracted from the request

func ExtractCredentials

func ExtractCredentials(r *http.Request) (*Credentials, error)

ExtractCredentials extracts authentication information from a http.Request

type Gateway

type Gateway struct {
	XbusOptions xbus.COptions
	Log         xbus.Logger
	Router      *mux.Router
	// contains filtered or unexported fields
}

Gateway provides a http router that handle a http-rest gateway to xbus

func NewGateway

func NewGateway(options xbus.COptions, logger xbus.Logger) *Gateway

NewGateway initializes a Gateway

func (*Gateway) OutputHandler

func (g *Gateway) OutputHandler(w http.ResponseWriter, r *http.Request)

OutputHandler is the handler for the '{actor}/output' route

func (*Gateway) ProcessRequestHandler

func (g *Gateway) ProcessRequestHandler(w http.ResponseWriter, r *http.Request)

ProcessRequestHandler is the handler for the '{actor}/processrequest' route

func (*Gateway) ProcessingEndHandler

func (g *Gateway) ProcessingEndHandler(w http.ResponseWriter, r *http.Request)

ProcessingEndHandler is the handler for the '{actor}/processingend' route

func (*Gateway) RequestHandler

func (g *Gateway) RequestHandler(w http.ResponseWriter, r *http.Request)

RequestHandler is the handler for the '{actor}/request' route

func (*Gateway) Shutdown

func (g *Gateway) Shutdown()

Shutdown the webhooks

func (*Gateway) Startup

func (g *Gateway) Startup() error

Startup starts handling the webhooks

type Header struct {
	Key   string
	Value string
}

type WebHookHandler

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

WebHookHandler ...

func (*WebHookHandler) Process

func (wh *WebHookHandler) Process(apc *xbus.ActorProcessingContext) error

Process a request

type WebHookPayloadType

type WebHookPayloadType string
const (
	// WebHookServiceName is the name of the webhook service in the registry
	WebHookServiceName = "http.webhook"

	WebHookPayloadFullRequest       WebHookPayloadType = "full-request"
	WebHookPayloadEnvelope          WebHookPayloadType = "envelope"
	WebHookPayloadMessageInRequest  WebHookPayloadType = "message-in-request"
	WebHookPayloadMessageInEnvelope WebHookPayloadType = "message-in-envelope"
	WebHookPayloadMessageContent    WebHookPayloadType = "message-content"
)

func WebHookPayloadTypeFromString

func WebHookPayloadTypeFromString(s string) (WebHookPayloadType, error)

Jump to

Keyboard shortcuts

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