controller

package
v0.0.0-...-8e48d4c Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransportMQTT = "MQTT"
	TransportHTTP = "HTTP"
)

Variables

This section is empty.

Functions

func Getenv

func Getenv(variable string) string

Getenv attempts to get the value of an environment variable from a file path. If the value is not a file path, it will use the value.

func GetenvMandatory

func GetenvMandatory(variable string) string

GetenvMandatory loads a mandatory environment variable and returns its value or terminates the process if the variable is unset.

func GetenvOptional

func GetenvOptional(variable string, defaultValue string) string

GetenvOptional loads an optional environment variable and returns its value or the provided default value if the varaible is not set.

func NewHTTPServer

func NewHTTPServer() *fiber.App

Types

type Controller

type Controller struct {
	APIGroup    string
	APIVersions []string `json:"apiVersions"`
	DB          *sqlx.DB
	Identity    *Identity
	HTTPServer  *fiber.App
	Version     string
}

Controller is the heart of the application that aggregates all functionality.

func New

func New() *Controller

New creates a new controller for the specified API group and version.

func (*Controller) ConnectDB

func (c *Controller) ConnectDB()

func (*Controller) Install

func (ctrl *Controller) Install(install InstallHook)

func (*Controller) Start

func (c *Controller) Start()

type EventContext

type EventContext struct {
	Source string
	HTTP   *fiber.Ctx
	MQTT   mqtt.Message
}

type EventHandler

type EventHandler func(*EventContext)

type Identity

type Identity struct {
	PublicKeyPEM    string            `json:"publicKeyPEM"`
	PrivateKey      crypto.PrivateKey `json:"-"`
	SignatureScheme SignatureScheme   `json:"signatureScheme"`
}

func NewIdentity

func NewIdentity(certDir string) *Identity

NewIdentity loads the keypair and the curve information.

type InstallHook

type InstallHook func(c *Controller) string

type Resource

type Resource interface {
}

type SignatureScheme

type SignatureScheme struct {
	// Algorithm can be either one of EdDSA, ECDSA or RSA.
	Algorithm string `json:"algorithm"`
	// Curve is the OpenSSL curve identifier. You can get
	// a list by running: openssl ecparam -list_curves
	Curve string `json:"curve,omitempty"`
	// Hash can be either SHA-256, SHA-384 or SHA-512.
	Hash string `json:"hash"`
}

SignatureScheme is a datatype roughly based on this section of RFC7518: https://datatracker.ietf.org/doc/html/rfc7518#section-3.1

var (
	// SchemeES256 is the equivalent of ES256 mentioned in RFC7518.
	SchemeES256 SignatureScheme = SignatureScheme{"ECDSA", "secp256r1", "SHA-256"}
	// SchemeES384 is the equivalent of ES384 mentioned in RFC7518.
	SchemeES384 SignatureScheme = SignatureScheme{"ECDSA", "secp384r1", "SHA-384"}
	// SchemeES512 is the equivalent of ES512 mentioned in RFC7518.
	SchemeES512 SignatureScheme = SignatureScheme{"ECDSA", "secp521r1", "SHA-512"}
)

func NewSignatureScheme

func NewSignatureScheme(curve string) SignatureScheme

func (SignatureScheme) String

func (s SignatureScheme) String() string

Jump to

Keyboard shortcuts

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