complete

command
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 11 Imported by: 0

README

Complete application example

This is the broad tour of HyperServe: templates and static files, health checks, security headers, bearer authentication, rate limiting, SSE, file uploads, recovery, and MCP in one process.

It is intentionally larger than the README quick start. Read main.go when you want to see how the features compose; start with hello-world when learning the basic server shape.

Run

From this directory:

go run .

Public endpoints include /, /static/, and /status. Routes under /api and the /mcp endpoint require one of the example bearer tokens:

curl -H "Authorization: Bearer demo-token-123" \
  http://localhost:8080/api/user

demo-token-123 maps to alice; demo-token-456 maps to bob.

The authentication flow is split into named steps:

verifier := auth.TokenVerifierFunc(verifyToken)
apiIdentity := auth.Bearer(verifier)
requireIdentity := auth.Require(apiIdentity)

srv.UsePrefix("/api", requireIdentity, server.RateLimitMiddleware(srv))
srv.UsePrefix("/mcp", requireIdentity)

Authentication answers “who is this?” The /api/user handler reads the resulting principal and remains responsible for the application decision about what that subject may see or change.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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