server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 8 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 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(
	port string,
	authSvc domain.AuthService,
	tenantSvc domain.TenantService,
	accountSvc domain.AccountService,
	categorySvc domain.CategoryService,
	transactionSvc domain.TransactionService,
	adminSvc domain.AdminService,
	idempotencyStore domain.IdempotencyStore,
	rateLimiterStore *middleware.RateLimiterStore,
	tokenParser middleware.TokenParser,
) *Server

NewServer is a factory function that creates and configures a new Server instance.

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