Download this file
| 1 | package home |
| 2 | |
| 3 | import ( |
| 4 | "net/http" |
| 5 | |
| 6 | "amadan.net/rastrillo/rastrillo" |
| 7 | ) |
| 8 | |
| 9 | // ServeOptions is what cmd/home hands rastrillo.Serve: Home's router |
| 10 | // under a mux, Home's reviewed security policy (noscript_test.go holds it), |
| 11 | // and two of the framework's own endpoints turned off. A seam, so a |
| 12 | // test can build the very handler Serve does (rastrillo.Handler) and |
| 13 | // see the layer outside Home's router. |
| 14 | // |
| 15 | // Since v0.38.0 Serve mounts, on every host, POST /_theme (it sets a |
| 16 | // rastrillo_scheme cookie without the __Host- prefix) and |
| 17 | // GET /_speculation-rules, and puts a Speculation-Rules header on every |
| 18 | // response. Home picks the scheme through its own Appearance form and |
| 19 | // prerenders nothing, and the credential origin must never carry a |
| 20 | // cookie Home did not mint, so both are off (TestServeAddsNoFrameworkRoutes). |
| 21 | func (a *App) ServeOptions(opts rastrillo.Options) rastrillo.Options { |
| 22 | mux := http.NewServeMux() |
| 23 | mux.Handle("/", a.Router()) |
| 24 | opts.Mux = mux |
| 25 | opts.CSP = a.SecurityPolicy() |
| 26 | opts.NoSchemeSwitch = true |
| 27 | opts.NoSpeculationRules = true |
| 28 | return opts |
| 29 | } |
| 30 | |