Version: v0.0.0-...-821bb50 Latest Latest

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 19 Imported by: 0




View Source
const (
	// WebHookServiceName is the name of the webhook service in the registry
	WebHookServiceName = "http.webhook"


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 occured that should not put the process in fail state")

ErrTemporaryError ...


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


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 WebHookHandler

type WebHookHandler struct {
	// contains filtered or unexported fields

WebHookHandler ...

func (*WebHookHandler) Process

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

Process a request

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL