summaryrefslogtreecommitdiff
path: root/api/types/types.go
diff options
context:
space:
mode:
authorElizabeth Alexander Hunt <me@liz.coffee>2026-06-20 09:40:07 -0700
committerElizabeth Alexander Hunt <me@liz.coffee>2026-06-20 09:40:07 -0700
commitfb653292612eddca5b088ed88466c546d1597107 (patch)
tree900ed32e066812688858ed3bb15128c41bb78054 /api/types/types.go
downloadpenguins.lan-fb653292612eddca5b088ed88466c546d1597107.tar.gz
penguins.lan-fb653292612eddca5b088ed88466c546d1597107.zip
Initial commit
Diffstat (limited to 'api/types/types.go')
-rw-r--r--api/types/types.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/api/types/types.go b/api/types/types.go
new file mode 100644
index 0000000..dc096d8
--- /dev/null
+++ b/api/types/types.go
@@ -0,0 +1,37 @@
+package types
+
+import (
+ "database/sql"
+ "net/http"
+ "time"
+
+ "penguins.lan/args"
+ "penguins.lan/database"
+)
+
+type RequestContext struct {
+ DBConn *sql.DB
+ Args *args.Arguments
+
+ Id string
+ Start time.Time
+
+ // User is the authenticated account (nil until resolved/required).
+ User *database.User
+ // ClientMAC is the visitor's hardware address, if we could read it.
+ ClientMAC string
+ // Nick mirrors User.Username for templates and the chat hub.
+ Nick string
+
+ TemplateData *map[string]interface{}
+}
+
+type BannerMessages struct {
+ Messages []string
+}
+
+// Continuation-passing style: each step is a Continuation that, given a
+// (success, failure) pair, returns the next link in the chain. This lets routes
+// read as a flat pipeline in serve.go while still branching on errors.
+type Continuation func(*RequestContext, *http.Request, http.ResponseWriter) ContinuationChain
+type ContinuationChain func(Continuation, Continuation) ContinuationChain