server

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package server implements the HTTP server for the Moolah API. It defines the Server struct, which holds references to all services and the HTTP handler. The server is responsible for starting and shutting down the HTTP server, as well as defining the routes in a separate file (routes.go).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.26.0

type Config struct {
	MasterPurchaseSvc domain.MasterPurchaseService
	InvestmentSvc     domain.InvestmentService
	RateLimitStore    domain.RateLimitStore
	AuthSvc           domain.AuthService
	TenantSvc         domain.TenantService
	AccountSvc        domain.AccountService
	Throttler         domain.Throttler
	CategorySvc       domain.CategoryService
	IdempotencyStore  domain.IdempotencyStore
	TransactionSvc    domain.TransactionService
	InvoiceCloser     domain.InvoiceCloser
	AdminSvc          domain.AdminService
	TokenParser       middleware.TokenParser
	Port              string
	OTPRateLimit      int
	OTPRatePeriod     time.Duration
}

Config holds the configuration for the Server.

type Server

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

Server is the main HTTP server for the API. It holds references to all services and the HTTP handler.

func New

func New(cfg Config) (*Server, error)

New creates and configures a new Server instance using a Config struct.

func (*Server) Handler added in v1.7.0

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

Handler returns the underlying http.Handler for testing purposes.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(ctx context.Context, readTimeout, writeTimeout time.Duration) error

ListenAndServe starts the HTTP server with the configured address and handler. It also sets the read and write timeouts.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the HTTP server, allowing in-flight requests to complete within the given context timeout.

Jump to

Keyboard shortcuts

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