oficina / calendar Public

Clone
git clone https://amadan.net/oficina/calendar

Plain git — no account needed to clone.

Download

Download this file

1package calendar
2
3import (
4 "log/slog"
5 "net/http"
6
7 rauth "amadan.net/rastrillo/rastrillo/auth"
8 "amadan.net/rastrillo/rastrillo/mail"
9)
10
11// handlers holds what every handler needs. One value, built in New.
12type handlers struct {
13 scheduled *scheduledWork
14 homeEnabled bool
15 directory string
16 store *Store
17 logger *slog.Logger
18
19 // origin is this instance's external origin. Handlers read it to
20 // decide Secure cookie attributes and to build the absolute URLs a
21 // calendar subscription needs.
22 origin string
23
24 // mailer sends reminders. The same sender sign-in uses, wrapped
25 // once in the bounded sender so every send is capped the same way.
26 mailer mail.Sender
27
28 // gate is the per-IP token bucket every public booking route
29 // passes through. One per app; memory only.
30 gate *gate
31 viewerFrom func(*http.Request) (rauth.Identity, bool)
32}
33
34// index serves GET / — the calendar itself.
35func (h *handlers) index(w http.ResponseWriter, r *http.Request) {
36 render(w, "index", h.page(r, "Calendar", nil))
37}
38