summaryrefslogtreecommitdiff
path: root/api/types/types.go
blob: dc096d8c15f559ca6c0ac6403d4ebe2d1eca9f2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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