app

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextEvent eventContext = "mopsos.event"
View Source
var ContextRecord eventContext = "mopsos.record"
View Source
var ContextUsername eventContext = "mopsos.username"

Functions

This section is empty.

Types

type App

type App struct {
	Server  *Server
	Handler *Handler
}

App is the application struct

func NewApp

func NewApp(c *Config, db *gorm.DB) (*App, error)

NewApp creates a new App

func (*App) Run

func (a *App) Run()

type Config

type Config struct {
	DBProvider string
	DBDSN      string
	DBMigrate  bool

	HttpListener   string
	BasicAuthUsers map[string]string

	EnableTracing bool
	TracingTarget string
}

Config type for config

type Handler

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

func NewHandler

func NewHandler(enableTracing bool, db *gorm.DB) *Handler

func (*Handler) HandleEvent

func (h *Handler) HandleEvent(data models.EventData) error

func (*Handler) HandleEvents

func (h *Handler) HandleEvents(eventChan chan models.EventData) error

HandleEvents blocks on the queue and handles events

type Server

type Server struct {
	EventChan chan<- models.EventData
	// contains filtered or unexported fields
}

Server is the main webserver struct

func NewServer

func NewServer(cfg *Config) *Server

NewServer creates a server that receives CloudEvents from the network

func (*Server) Authenticate added in v0.3.3

func (s *Server) Authenticate(next http.Handler) http.Handler

Authenticate middleware handles checking credentials

func (*Server) HandleHealthCheck added in v0.3.3

func (s *Server) HandleHealthCheck(w http.ResponseWriter, r *http.Request)

func (*Server) HandleWebhook added in v0.3.3

func (s *Server) HandleWebhook(w http.ResponseWriter, r *http.Request)

func (*Server) LoadEvent added in v0.3.3

func (s *Server) LoadEvent(next http.Handler) http.Handler

LoadEvent middlerware loads event from the request

func (*Server) Start

func (s *Server) Start()

Start starts the server and listens for incoming events

func (*Server) Validate added in v0.3.3

func (s *Server) Validate(next http.Handler) http.Handler

Validate middleware handles checking received events for validity

func (*Server) WithEventChannel

func (s *Server) WithEventChannel(eventChan chan<- models.EventData) *Server

WithEventChannel sets the event channel for the server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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