setup

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrJWKSet = errors.New("JWK Set did not align with setup expectations")

ErrJWKSet is returned when the JWK Set does not align with setup expectations.

Functions

func CreateKeysIfNotExists

func CreateKeysIfNotExists(ctx context.Context, store storage.Storage) (keys []jwkset.KeyWithMeta[storage.JWKSetCustomKeyMeta], existed bool, err error)

CreateKeysIfNotExists creates the keys if they do not exist.

func CreateLogger

func CreateLogger(srvConf config.Config) *slog.Logger

func CreateMultiProviderServer

func CreateMultiProviderServer(ctx context.Context, conf MultiConfig, options ServerOptions) (*handle.Server, error)

CreateMultiProviderServer creates a new magiclinksdev server with multiple email providers.

func CreateNopProviderServer

func CreateNopProviderServer(ctx context.Context, conf NopConfig, options ServerOptions) (*handle.Server, error)

CreateNopProviderServer creates a new magiclinksdev server with a no-operation email provider.

func CreateSESProvider

func CreateSESProvider(ctx context.Context, conf SESConfig, options ServerOptions) (*handle.Server, error)

CreateSESProvider creates a new magiclinksdev server with a SES email provider.

func CreateSendGridProvider

func CreateSendGridProvider(ctx context.Context, conf SendGridConfig, options ServerOptions) (*handle.Server, error)

CreateSendGridProvider creates a new magiclinksdev server with a SendGrid email provider.

func CreateServer

func CreateServer(ctx context.Context, conf config.Config, options ServerOptions, interfaces ServerInterfaces) (*handle.Server, error)

CreateServer creates a new magiclinksdev server.

func CreateTestingProvider

func CreateTestingProvider(ctx context.Context, conf TestConfig, options ServerOptions) (*handle.Server, error)

CreateTestingProvider creates a new magiclinksdev server with a testing email provider.

func MagicLinkErrorHandler

func MagicLinkErrorHandler(h magiclink.ErrorHandler) magiclink.ErrorHandler

MagicLinkErrorHandler is a wrapper for magiclink.ErrorHandlerFunc.

func RunServer

func RunServer(ctx context.Context, logger *slog.Logger, server *handle.Server)

Types

type MultiConfig

type MultiConfig struct {
	SES         ses.Config      `json:"ses"`
	SendGrid    sendgrid.Config `json:"sendgrid"`
	Server      config.Config   `json:"server"`
	Storage     postgres.Config `json:"storage"`
	RateLimiter rlimit.Config   `json:"rateLimiter"`
}

MultiConfig is the configuration for a multiple email provider magiclinksdev server.

func (MultiConfig) DefaultsAndValidate

func (m MultiConfig) DefaultsAndValidate() (MultiConfig, error)

DefaultsAndValidate implements the jsontype.Config interface.

type NopConfig

type NopConfig struct {
	Server      config.Config   `json:"server"`
	Storage     postgres.Config `json:"storage"`
	RateLimiter rlimit.Config   `json:"rateLimiter"`
}

NopConfig is the configuration for a no-operation email provider magiclinksdev server.

func (NopConfig) DefaultsAndValidate

func (n NopConfig) DefaultsAndValidate() (NopConfig, error)

DefaultsAndValidate implements the jsontype.Config interface.

type SESConfig

type SESConfig struct {
	SES         ses.Config      `json:"ses"`
	Server      config.Config   `json:"server"`
	Storage     postgres.Config `json:"storage"`
	RateLimiter rlimit.Config   `json:"rateLimiter"`
}

SESConfig is the configuration for a single email provider magiclinksdev server.

func (SESConfig) DefaultsAndValidate

func (s SESConfig) DefaultsAndValidate() (SESConfig, error)

DefaultsAndValidate implements the jsontype.Config interface.

type SendGridConfig

type SendGridConfig struct {
	SendGrid    sendgrid.Config `json:"sendgrid"`
	Server      config.Config   `json:"server"`
	Storage     postgres.Config `json:"storage"`
	RateLimiter rlimit.Config   `json:"rateLimiter"`
}

SendGridConfig is the configuration for the SendGrid email provider.

func (SendGridConfig) DefaultsAndValidate

func (m SendGridConfig) DefaultsAndValidate() (SendGridConfig, error)

DefaultsAndValidate implements the jsontype.Config interface.

type ServerInterfaces

type ServerInterfaces struct {
	EmailProvider email.Provider
	RateLimiter   rlimit.RateLimiter
	Store         storage.Storage
}

ServerInterfaces holds all the interface implementations needed for a magiclinksdev server.

type ServerOptions

type ServerOptions struct {
	HTTPMux               *http.ServeMux
	Logger                *slog.Logger
	MagicLinkErrorHandler magiclink.ErrorHandler
	MiddlewareHook        handle.MiddlewareHook
}

ServerOptions holds all the options for a magiclinksdev server.

func (ServerOptions) ApplyDefaults

func (o ServerOptions) ApplyDefaults() ServerOptions

ApplyDefaults applies the default values to the options.

type TestConfig

type TestConfig struct {
	Server      config.Config   `json:"server"`
	Storage     postgres.Config `json:"storage"`
	RateLimiter rlimit.Config   `json:"rateLimiter"`
}

TestConfig is the configuration for a test magiclinksdev server.

func (TestConfig) DefaultsAndValidate

func (t TestConfig) DefaultsAndValidate() (TestConfig, error)

DefaultsAndValidate implements the jsontype.Config interface.

Jump to

Keyboard shortcuts

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