http

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package http2 provides an HTTP server comprised of multiple HTTP services

Index

Constants

This section is empty.

Variables

View Source
var ProvidersHTTP = wire.NewSet(
	ProvideHTTPServer,
)

ProvidersHTTP are our wire superset of providers this package offers.

Functions

func RegisterHTTPServer

func RegisterHTTPServer(i do.Injector, serviceName string)

RegisterHTTPServer registers a Server with the injector. The serviceName parameter is passed directly rather than injected, since string is too generic a type to resolve unambiguously from the injector.

func RootLevelAssetsHandler

func RootLevelAssetsHandler(assetsDir string) http.HandlerFunc

RootLevelAssetsHandler returns an http.HandlerFunc that serves static files from assetsDir. It only serves root-level files (no subdirectories) and guards against path traversal. Register with router.Get("/*", RootLevelAssetsHandler(assetsDir)) as the last route.

Types

type Config

type Config struct {
	SSLCertificateFile    string        `env:"SSL_CERTIFICATE_FILEPATH"     json:"sslsCertificate,omitempty"`
	SSLCertificateKeyFile string        `env:"SSL_CERTIFICATE_KEY_FILEPATH" json:"sslsCertificateKey,omitempty"`
	StartupDeadline       time.Duration `env:"STARTUP_DEADLINE"             json:"startupDeadline,omitempty"`
	Port                  uint16        `env:"PORT"                         json:"port"`
	Debug                 bool          `env:"DEBUG"                        json:"debug"`
	// contains filtered or unexported fields
}

Config describes the settings pertinent to the HTTP serving portion of the service.

func (*Config) ValidateWithContext

func (cfg *Config) ValidateWithContext(ctx context.Context) error

ValidateWithContext validates a Config struct.

type Server

type Server interface {
	Serve()
	Shutdown(context.Context) error
	Router() routing.Router
}

func ProvideHTTPServer

func ProvideHTTPServer(
	serverSettings Config,
	logger logging.Logger,
	router routing.Router,
	tracerProvider tracing.TracerProvider,
	serviceName string,
) (Server, error)

ProvideHTTPServer builds a new server instance. serviceName, when non-empty, is used for the server's logger; otherwise "api_server" is used.

Jump to

Keyboard shortcuts

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