Documentation
¶
Overview ¶
Package server provides the Firepit HTTP server. This file maps CSIL service and operation names to the generated service interfaces.
Wire naming for (service, op) ¶
csilgen does not generate a router for its Go server target, so this table is maintained by hand.
The (service, op) strings a real request carries are NOT the PascalCase interface/method names or the CSIL schema's `AuthService`-with-suffix service identifiers — they're what csilgen's *-client generators actually derive and what the one real, test-verified precedent in this org (longhouse's TypeScript transport, webapp/src/transport/csilrpc.ts there) puts on the wire:
- service: the CSIL service name with a trailing "Service" stripped and lowercased ("AuthService" -> "auth"; see clients/go/client.gen.go, which already calls transport.Call(ctx, "auth", "BeginLogin", ...)).
- op: the operation name exactly as declared in csil/firepit.csil, kebab-case ("begin-login") — csilgen's generated clients hand a PascalCase method name to the Transport seam and expect the carrier to kebab-case it before it hits the wire (longhouse's methodToOp); the routing table below is keyed directly on the already-kebab-case op names from the schema, so no runtime conversion is needed server-side.
This file registers the GitHub webhook route. The github package verifies and processes each event.
Index ¶
Constants ¶
const SessionCookieName = "firepit_session"
SessionCookieName is the cookie firepit's own session lives in (PLANDOC.md §3: "Sessions are firepit's; linkkeys only verifies identity"). There is no longhouse precedent to mirror here — longhouse is bearer-JWT-only, no cookies at all — so this name is new to firepit; B2 (which mints the cookie on successful login, server/authcallback.go) reuses this exact constant rather than a hardcoded string.
Variables ¶
This section is empty.
Functions ¶
func CurrentUser ¶
CurrentUser returns the user attached to ctx by the session middleware, or ok=false if the caller has no valid session — which is a normal, expected state (anonymous read), never an error on its own. Individual service methods decide whether anonymous access is allowed for a given op; this helper just answers "who, if anyone."
Delegates to reqctx.User (api/internal/reqctx): the context key/storage lives there because csilservices (every service implementation, this task's AuthService.Whoami included) cannot import this package without a cycle (dispatch.go already imports csilservices the other way), and reqctx is the shared, dependency-free package both sides depend on instead. This wrapper keeps server.CurrentUser's name, signature, and doc contract unchanged for any caller that already used it.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is firepit-api's HTTP surface: CSIL-RPC dispatch, session middleware, /healthz, CORS, and request logging.
func New ¶
New constructs a Server. svcs supplies one implementation per generated csil service (see Services). pub is the same notify.Publisher main.go wires into the CSIL services (notify.NewDBPublisher in production) — registerGithubWebhookRoutes passes it to the GitHub webhook handler too, so every content-creating path (CSIL-RPC or GitHub ingestion) fans out notifications through the one implementation.
func (*Server) Handler ¶
Handler builds the full middleware chain around the mux: CORS (outermost, so even a rejected/OPTIONS request gets CORS headers) -> request logging -> session -> mux.
func (*Server) ListenAndServe ¶
ListenAndServe starts the HTTP server and blocks until ctx is canceled, at which point it drains in-flight requests (graceful shutdown) before returning. A listener error returns immediately without waiting for ctx.
type Services ¶
type Services struct {
Auth csil.AuthService
Board csil.BoardService
Category csil.CategoryService
Thread csil.ThreadService
Endorsement csil.EndorsementService
Settings csil.SettingsService
Social csil.SocialService
Subscription csil.SubscriptionService
Read csil.ReadService
Notification csil.NotificationService
Integration csil.IntegrationService
}
Services bundles one implementation per generated CSIL service interface.