server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RegionEndpoints = map[Region]string{
	RegionEU: "sellingpartnerapi-eu.amazon.com",
	RegionNA: "sellingpartnerapi-na.amazon.com",
	RegionFE: "sellingpartnerapi-fe.amazon.com",
}

RegionEndpoints maps each region to its Amazon SP-API hostname.

Functions

func NewHealthHandler

func NewHealthHandler() http.Handler

NewHealthHandler returns an HTTP handler that serves health/readiness endpoints on the dashboard port.

Types

type HandlerFactory

type HandlerFactory func(region Region) http.Handler

HandlerFactory creates an HTTP handler for a given region. Each region gets its own handler (with its own reverse proxy pointed at the correct Amazon endpoint).

type Region

type Region string

Region identifies an Amazon SP-API regional endpoint.

const (
	RegionEU Region = "eu"
	RegionNA Region = "na"
	RegionFE Region = "fe"
)

func AllRegions

func AllRegions() []Region

AllRegions returns all supported regions in deterministic order.

type Server

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

Server manages multiple HTTP listeners: one per SP-API region + dashboard.

func New

func New(cfg *config.Config, factory HandlerFactory, dashboardHandler http.Handler) (*Server, error)

New creates a new Server. factory creates the HTTP handler for each region. Pass nil for dashboard-only mode (all proxy ports serve 404).

func (*Server) DashboardAddr

func (s *Server) DashboardAddr() string

DashboardAddr returns the dashboard listen address, or "" if not started.

func (*Server) RegionAddr

func (s *Server) RegionAddr(region Region) string

RegionAddr returns the listen address for a region, or "" if disabled.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown gracefully stops all listeners, draining in-flight requests. It is idempotent: the second and subsequent calls are no-ops that return nil.

func (*Server) Start

func (s *Server) Start() error

Start begins listening on all configured ports. Blocks until Shutdown is called or an OS signal is received.

Jump to

Keyboard shortcuts

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