server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server)

Option configures server creation.

func WithLogger

func WithLogger(log *slog.Logger) Option

WithLogger sets the server logger.

type Server

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

Server is a shared HTTP server with routing, identity, and optional frontend serving.

func New

func New(opts ...Option) *Server

New creates a new Server with RequestLogging, CORS, and /healthz.

func (*Server) IdentityMiddleware

func (s *Server) IdentityMiddleware() func(http.Handler) http.Handler

IdentityMiddleware returns middleware that uses Tailscale identity if configured, otherwise falls back to DevIdentity.

func (*Server) Router

func (s *Server) Router() chi.Router

Router returns the chi.Router for adding application routes.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

func (*Server) SetFrontend

func (s *Server) SetFrontend(webFS fs.FS)

SetFrontend mounts the embedded SPA filesystem. Unmatched routes serve index.html for client-side routing. Hashed assets get long cache; index.html is never cached.

func (*Server) SetMCP

func (s *Server) SetMCP(mcpSrv *mcpserver.MCPServer, userIDInjector func(ctx context.Context, r *http.Request) context.Context)

SetMCP mounts an MCP server at /mcp with identity middleware. userIDInjector is called to inject the user ID into the MCP context.

func (*Server) SetTailscale

func (s *Server) SetTailscale(lc middleware.WhoisClient, us middleware.UserStore)

SetTailscale configures Tailscale identity resolution.

Jump to

Keyboard shortcuts

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