appcore

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: MIT Imports: 22 Imported by: 0

README

appsap-core

Getting Started

Appsap-core framework

Installation

Run the following command to install the package:

go get github.com/mortired/appsap-core

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EchoServer = Options(
	Invoke(StartEchoServer),
)

HMACModule optional module for HMAC authentication

LifecycleModule provides lifecycle hooks

View Source
var LoggingModule = Options(
	Provide(ProvideLogger),
)

LoggingModule provides logger instance

Functions

func LoggerMiddleware

func LoggerMiddleware() echo.MiddlewareFunc

LoggerMiddleware creates a custom logger middleware that includes TraceID

func NewFxDebugLogger

func NewFxDebugLogger(logger *logging.Logger) fxevent.Logger

NewFxDebugLogger creates custom logger for fx debugging

func NewFxEvents

func NewFxEvents(cfg FxEventsConfig) []fx.Option

NewFxEvents creates and returns fx options for events configuration

func ProvideConfig

func ProvideConfig() *config.Config

func ProvideEchoServer

func ProvideEchoServer() *echo.Echo

ProvideEchoServer creates HTTP Echo server

func ProvideHMACMiddleware

func ProvideHMACMiddleware(cfg HMACConfig) middleware.HMACConfig

ProvideHMACMiddleware creates HMAC middleware with configuration

func ProvideLogger

func ProvideLogger() (*logging.Logger, error)

ProvideLogger creates logger instance with optional Elasticsearch integration

func SetupEchoMiddleware

func SetupEchoMiddleware(e *echo.Echo, logger *logging.Logger)

SetupEchoMiddleware sets up Echo middleware with logger

func SetupGracefulShutdown

func SetupGracefulShutdown(lifecycle fx.Lifecycle, logger *logging.Logger)

SetupGracefulShutdown sets up graceful shutdown handling

func SetupHMACMiddleware

func SetupHMACMiddleware(e *echo.Echo, config middleware.HMACConfig, logger *logging.Logger)

SetupHMACMiddleware configures HMAC middleware

func StartEchoServer

func StartEchoServer(lifecycle fx.Lifecycle, e *echo.Echo, cfg *config.Config, logger *logging.Logger)

StartEchoServer starts HTTP server

func StopEchoServer

func StopEchoServer(e *echo.Echo, logger *logging.Logger)

StopEchoServer gracefully stops HTTP server

Types

type Application

type Application struct {
	*fx.App
}

Application represents application with dependency injection

func New

func New(options ...fx.Option) *Application

New creates a new application with given options

func (*Application) Run

func (app *Application) Run()

Run starts the application

func (*Application) Start

func (app *Application) Start(ctx context.Context) error

Start starts the application in background mode

func (*Application) Stop

func (app *Application) Stop(ctx context.Context) error

Stop stops the application

type FxEventsConfig

type FxEventsConfig struct {
	FxEnabled bool
	FxDebug   bool
	FxVerbose bool
	ShowGraph bool
}

FxEventsConfig structure for fx events configuration

type HMACConfig

type HMACConfig struct {
	ClientSecrets []middleware.HMACClientSecret
	RouteRights   middleware.HMACRouteRights
	Algorithm     string
	MaxAge        int
	Required      bool
}

HMACConfig structure for HMAC configuration Allows infrastructure to not depend on application packages

func ProvideHMACConfig

func ProvideHMACConfig(logger *logging.Logger) (HMACConfig, error)

ProvideHMACConfig creates HMAC configuration from environment variables

type LifecycleHooks

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

LifecycleHooks provides lifecycle hooks for the application

func NewLifecycleHooks

func NewLifecycleHooks(logger *logging.Logger) *LifecycleHooks

NewLifecycleHooks creates new lifecycle hooks

func (*LifecycleHooks) OnStart

func (lh *LifecycleHooks) OnStart(ctx context.Context) error

OnStart logs application start

func (*LifecycleHooks) OnStop

func (lh *LifecycleHooks) OnStop(ctx context.Context) error

OnStop logs application stop

type Option

type Option = fx.Option

Option represents an option for application configuration

func Invoke

func Invoke(funcs ...interface{}) Option

Invoke creates an option for invoking function

func Options

func Options(opts ...Option) Option

Options combines multiple options

func Provide

func Provide(constructors ...interface{}) Option

Provide creates an option for providing dependency

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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