summaryrefslogtreecommitdiff
path: root/api/types/types.go
diff options
context:
space:
mode:
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