server

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServeCmd = &cobra.Command{
	Use:          "serve",
	Short:        "Start the API server",
	Long:         "Start the Waypoint API server. The server provides IP geolocation endpoints and optionally serves the web UI.",
	Aliases:      []string{"server", "run"},
	SilenceUsage: true,
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := cmd.Context()

		dbConn, err := db.New(ctx, config.Current)
		if err != nil {
			return err
		}

		mmClient := maxmind.NewClient(&config.Current.MaxMind, config.Current.Core.DataDir)

		if config.Current.Core.Environment != config.EnvironmentDevelopment {
			if err := mmClient.DownloadAllDB(); err != nil {
				return err
			}
		} else {

			if err := mmClient.Load(); err != nil {
				slog.Warn("Failed to load MaxMind databases", "error", err)
			}
		}

		if config.Current.MaxMind.AutoUpdate {
			go mmClient.RunDBDownloadJob(ctx)
		}

		server := NewServer(ctx, config.Current, mmClient, dbConn.DB)
		if err := server.Init(); err != nil {
			return err
		}

		return server.serve()
	},
}

ServeCmd represents the server command.

Functions

This section is empty.

Types

type Server

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

Server represents the HTTP server.

func NewServer

func NewServer(ctx context.Context, cfg *config.Config, mm *maxmind.Client, db *gorm.DB) *Server

NewServer creates a new Server instance.

func (*Server) Init

func (s *Server) Init() error

Init initializes the server with handlers, routes and middleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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