httpserver

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicAuth added in v0.0.9

type BasicAuth struct {
	// Username is the username for basic auth.
	Username string
	// Password is the password for basic auth.
	Password string
	// Realm is the realm for basic auth.
	Realm string
}

BasicAuth is a struct that holds basic auth information.

type Carrier

type Carrier struct {
	Config        *Config
	Logger        journal.Logger
	Context       context.Context
	MessageLookup map[uuid.UUID]MessageStatus
	PostHandler   HTTPRequestHandler

	sync.Mutex
}

Carrier signifies the http server input carrier for the meander flow framework.

func New

func New(ctx context.Context, logger journal.Logger, config *Config, postHandler HTTPRequestHandler) (*Carrier, error)

func (*Carrier) AcknowledgeMessage

func (c *Carrier) AcknowledgeMessage(message *flow.MessageContext, err error) error

AcknowledgeMessage sets a message to successful if no error given, failed if an error is given.

func (*Carrier) InternalError

func (c *Carrier) InternalError(message *flow.MessageContext, err error) error

InternalError sets a message to failed.

func (*Carrier) SetupInput

func (c *Carrier) SetupInput(inChan chan *flow.MessageContext) error

type CertFiles

type CertFiles struct {
	// Certificate is the name of the certificate file.
	Certificate string
	// Key is the name of the key file.
	Key string
}

CertFiles contain the names of the certificate and the key of the certificates to use.

type Config

type Config struct {
	// ListenAddress -- The address to listen on.
	// Default: 0.0.0.0
	ListenAddress string
	// Port -- The port to listen on, only used when TLS is not enabled
	// Default: 80 when TLS is disabled, 443 when TLS is enabled.
	Port int
	// EnableTLS -- Enable TLS
	// Default: false
	EnableTLS bool
	// CertDirectory -- The directory certificate files live in, or where LetsEncrypt writes its
	// certificate files.
	// Required if TLS enabled.
	CertDirectory string
	// Hostnames -- the hostnames to use for TLS
	// Default empty, required for TLS.
	Hostnames []string
	// EnableLetsEncrypt -- Acquire TLS certificate from LetsEncrypt
	// Default false
	EnableLetsEncrypt bool
	// CertFiles -- The name of the certificate/key files to use.
	// This will be ignored if EnableLetsEncrypt is set to true.
	CertFiles CertFiles
	// BasicAuth -- A basic auth struct, if nil, no basic auth will be setup.
	BasicAuth *BasicAuth
}

Config is the httpserver configuration struct.

type HTTPRequestHandler added in v0.0.25

type HTTPRequestHandler func(
	req *http.Request,
	logger journal.Logger,
	c *Carrier,
	inChan chan *flow.MessageContext,
	w http.ResponseWriter,
)

type MessageStatus added in v0.0.26

type MessageStatus uint8
const (
	MessagePending MessageStatus = iota
	MessageFailed
	MessageSuccess
)

Jump to

Keyboard shortcuts

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