appkit

module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0

README

appkit

A composable Go framework for HTTP applications, including configuration, authentication, sessions, logging, encryption, and web serving.

Install

go get github.com/containeroo/appkit

Example

Define your application and management routes, then serve them independently:

app := http.NewServeMux()
app.HandleFunc("GET /", home)

management := http.NewServeMux()
management.HandleFunc("GET /healthz", health)
management.HandleFunc("GET /readyz", readiness)

serverConfig := httpserver.Config{
    Application: app,
    Management:  management,
    RoutePrefix: cfg.Server.RoutePrefix,
}
handlers := httpserver.New(serverConfig)
if err := httpserver.Run(
    ctx,
    cfg.Server.ListenAddress,
    cfg.Server.ManagementListenAddress,
    handlers,
    logger.With("component", "server"),
); err != nil {
    logger.Error("run server", "event", "server_run_failed", "error", err)
    return err
}

See examples/basic for a complete runnable example with configuration flags, logging, graceful shutdown, and both listeners.

go run ./examples/basic --route-prefix /app

curl http://127.0.0.1:8080/app/
curl -i http://127.0.0.1:8081/healthz

Proxy authentication may restrict immediate ingress peers with proxy.TrustCIDRs and config.Proxy.TrustedCIDRs. Use httpauth.AuthorizeWithError for authorization checks that can fail independently of access denial. web.SPA renders the entry point as a Go template, while httpkit/assets.Static serves static files.

Directories

Path Synopsis
Package auth defines application-independent authentication contracts and errors.
Package auth defines application-independent authentication contracts and errors.
local
Package local provides password hashing and verification for application-owned user stores.
Package local provides password hashing and verification for application-owned user stores.
oidc
Package oidc provides a reusable, storage-independent OpenID Connect authorization-code flow.
Package oidc provides a reusable, storage-independent OpenID Connect authorization-code flow.
provisioning
Package provisioning coordinates external identities with application-owned user storage.
Package provisioning coordinates external identities with application-owned user storage.
proxy
Package proxy accepts externally asserted identities only from explicitly trusted requests.
Package proxy accepts externally asserted identities only from explicitly trusted requests.
session
Package session implements opaque, purpose-bound, hashed browser sessions.
Package session implements opaque, purpose-bound, hashed browser sessions.
Package config registers optional, reusable deployment flag groups with tinyflags.
Package config registers optional, reusable deployment flag groups with tinyflags.
examples
basic command
Command basic runs an HTTP application with a separate operational listener.
Command basic runs an HTTP application with a separate operational listener.
Package httpauth bridges application-owned users and authenticators into net/http.
Package httpauth bridges application-owned users and authenticators into net/http.
Package httpserver composes application and management HTTP handlers and serves them independently.
Package httpserver composes application and management HTTP handlers and serves them independently.
Package secrets encrypts sensitive application settings with a deployment-managed key.
Package secrets encrypts sensitive application settings with a deployment-managed key.
Package web serves embedded single-page applications with optional Go-template index data.
Package web serves embedded single-page applications with optional Go-template index data.

Jump to

Keyboard shortcuts

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