pacific

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package pacific provides HTTP server code shared between both proxies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadServerTLSConfig added in v0.0.2

func LoadServerTLSConfig(certPath, keyPath, caPath string) (*tls.Config, error)

LoadServerTLSConfig reads the server certificate, key, and CA certificate from the given paths and returns a tls.Config for mutual TLS.

func Logger

func Logger(ctx context.Context) zerolog.Logger

Logger returns the request-scoped logger from ctx, or the default logger.

func LoggerMiddleware

func LoggerMiddleware(next http.Handler) http.Handler

LoggerMiddleware attaches a request-scoped logger to the request context.

Types

type Certificates added in v0.0.2

type Certificates struct {
	CACertPEM     []byte
	CAKeyPEM      []byte
	ServerCertPEM []byte
	ServerKeyPEM  []byte
	ClientCertPEM []byte
	ClientKeyPEM  []byte
}

Certificates holds the PEM-encoded keys and certificates needed to establish a mutually authenticated TLS connection.

func GenerateCertificates added in v0.0.2

func GenerateCertificates() (*Certificates, error)

GenerateCertificates creates a self-signed CA along with server and client certificates signed by that CA, suitable for mutual TLS.

func (*Certificates) ClientTLSConfig added in v0.0.2

func (c *Certificates) ClientTLSConfig() (*tls.Config, error)

ClientTLSConfig returns a tls.Config that presents the client certificate and verifies the server against the CA.

func (*Certificates) ServerTLSConfig added in v0.0.2

func (c *Certificates) ServerTLSConfig() (*tls.Config, error)

ServerTLSConfig returns a tls.Config that presents the server certificate and requires clients to present a certificate signed by the CA.

type Server

type Server[T any] struct {
	// contains filtered or unexported fields
}

Server is an HTTP server that builds a request-scoped context per request.

func NewServer

func NewServer[T any](contextCreator func(w http.ResponseWriter, r *http.Request) T) *Server[T]

NewServer creates a server that derives per-request context via creator.

func (*Server[T]) AddRoute

func (s *Server[T]) AddRoute(method string, pattern string, handler func(T))

AddRoute registers a handler for the given method and pattern.

func (*Server[T]) Serve

func (s *Server[T]) Serve(listenAddr string) error

Serve listens on listenAddr and serves HTTP requests.

func (*Server[T]) ServeTLS added in v0.0.2

func (s *Server[T]) ServeTLS(listenAddr string, tlsConfig *tls.Config) error

ServeTLS listens on addr and serves over TLS using the provided config. The config's Certificates and ClientAuth fields must be set for mutual TLS.

Jump to

Keyboard shortcuts

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