Documentation
¶
Index ¶
- Constants
- func FeatureGate(enabled func() bool, notFound http.HandlerFunc) func(http.Handler) http.Handler
- func FileServerWithCache(root, cacheControl string) http.Handler
- func RegisterAdminRoutes(r *http.ServeMux, store *sessions.CookieStore, ac *admin.Controller, ...)
- func RegisterCommentRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterEmbedsRoutes(r *http.ServeMux, store *sessions.CookieStore, ec *interfaces.EmbedsController)
- func RegisterNodeRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterNodeSearchRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterPrivateFilesRoutes(r *http.ServeMux, pc *interfaces.PrivateFilesController)
- func RegisterRecentChangesRoute(r *http.ServeMux, store *sessions.CookieStore, userRepo entity.UserRepository, ...)
- func RegisterRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterRssRoutes(r *http.ServeMux, rc *interfaces.RssController)
- func RegisterSearchRoutes(r Mux, sc *interfaces.SearchController, rl *ratelimit.RateLimiter)
- func RegisterSitemapRoutes(r *http.ServeMux, sc *interfaces.SitemapController)
- func RegisterStaticRoutes(r *http.ServeMux)
- func RegisterStylesRoutes(r *http.ServeMux, sc *interfaces.StylesController)
- func RegisterTaxonomyRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterUserFilesRoutes(r *http.ServeMux, store *sessions.CookieStore, ...)
- func RegisterUserRoutes(r *http.ServeMux, store *sessions.CookieStore, uc *interfaces.UserController, ...)
- func RegisterViewCountRoutes(r *http.ServeMux, vc *interfaces.ViewCountController, ...)
- func UploadsFileServer(store filestore.Store, storeURL func() string, cacheControl string) http.Handler
- type Mux
- type UserRateLimits
Constants ¶
const ( // CacheStatic is for versioned assets under /static/ (CSS/JS use ?v= query). CacheStatic = "public, max-age=31536000, immutable" // CacheUploads is for uploaded files under /sites/ (no immutable - same path may be replaced). CacheUploads = "public, max-age=31536000" )
Variables ¶
This section is empty.
Functions ¶
func FeatureGate ¶
FeatureGate answers 404 while enabled reports false: API paths with a JSON error, pages with notFound.
func FileServerWithCache ¶
FileServerWithCache serves the files under root (not its folders' listings, not dotfiles) and sets Cache-Control on every response.
func RegisterAdminRoutes ¶
func RegisterAdminRoutes( r *http.ServeMux, store *sessions.CookieStore, ac *admin.Controller, dc *interfaces.DynamicContentController, sg *interfaces.StyleguideController, userRepo entity.UserRepository, authService service.AuthService, )
RegisterAdminRoutes registers the admin's pages: content, people, configuration, the content model, the site structure and the Views, for who may access the admin (and, for some, holds a further permission).
func RegisterCommentRoutes ¶
func RegisterCommentRoutes(r *http.ServeMux, store *sessions.CookieStore, cc *interfaces.CommentController, commentsRL, commentPostRL *ratelimit.RateLimiter)
RegisterCommentRoutes registers the comments' routes: the recent ones, a comment's link, a node's comments (limited by commentsRL), posting one (signed in, limited by commentPostRL), editing and deleting.
func RegisterEmbedsRoutes ¶
func RegisterEmbedsRoutes(r *http.ServeMux, store *sessions.CookieStore, ec *interfaces.EmbedsController)
RegisterEmbedsRoutes - the editor's "Insert" window and the cards over the embed tags (interfaces.EmbedsController); signed-in users only.
func RegisterNodeRoutes ¶
func RegisterNodeRoutes( r *http.ServeMux, store *sessions.CookieStore, nodeController *interfaces.NodeController, nodeRepo entity.NodesRepository, userRepo entity.UserRepository, authService service.AuthService, nodeDispatcher *interfaces.NodeDispatcher, notFoundHTML http.HandlerFunc, )
RegisterNodeRoutes registers creating, editing, deleting, cloning, publishing and unpublishing content (each behind the node access check its action needs), its preview links and history, the media picker of its forms and the recent changes (RegisterRecentChangesRoute).
func RegisterNodeSearchRoutes ¶
func RegisterNodeSearchRoutes(r *http.ServeMux, store *sessions.CookieStore, nsc *interfaces.NodeSearchController, rl *ratelimit.RateLimiter)
RegisterNodeSearchRoutes - the cross-type node title search (see interfaces.NodeSearchController) behind the node pickers of edit forms (menu links, reference fields); signed-in users only.
func RegisterPrivateFilesRoutes ¶
func RegisterPrivateFilesRoutes(r *http.ServeMux, pc *interfaces.PrivateFilesController)
RegisterPrivateFilesRoutes - the private files of file fields, served after the access check (interfaces.PrivateFilesController).
func RegisterRecentChangesRoute ¶
func RegisterRecentChangesRoute(r *http.ServeMux, store *sessions.CookieStore, userRepo entity.UserRepository, authService service.AuthService, nodeController *interfaces.NodeController)
RegisterRecentChangesRoute registers the recent changes of all the content (Content → Changes): an admin page; the handler checks the history's permission and which types' content to show.
func RegisterRoutes ¶
func RegisterRoutes( r *http.ServeMux, store *sessions.CookieStore, nodeDispatcher *interfaces.NodeDispatcher, nodeRepo entity.NodesRepository, userRepo entity.UserRepository, authService service.AuthService, ic *interfaces.IndexController, notFoundHTML http.HandlerFunc, dynamicListFallback func(w http.ResponseWriter, r *http.Request) bool, )
RegisterRoutes registers the site's own routes: the CSRF token for a page's script, the home page, the catch-all route serving content by its address (with the fallbacks for an address no node has: a View's page, /node/<id>) and the lazy blocks' and View blocks' pages.
func RegisterRssRoutes ¶
func RegisterRssRoutes(r *http.ServeMux, rc *interfaces.RssController)
RegisterRssRoutes registers the site's RSS feed (/rss.xml), rendered as for a guest.
func RegisterSearchRoutes ¶
func RegisterSearchRoutes(r Mux, sc *interfaces.SearchController, rl *ratelimit.RateLimiter)
RegisterSearchRoutes - the live search and the results page; a query scans the content, so rl limits them per client.
func RegisterSitemapRoutes ¶
func RegisterSitemapRoutes(r *http.ServeMux, sc *interfaces.SitemapController)
RegisterSitemapRoutes registers robots.txt and the sitemap (rendered as for a guest): its index, the static pages and the content in chunks.
func RegisterStaticRoutes ¶
RegisterStaticRoutes serves /static (versioned assets) and the public files (uploads: paths.PublicStore at paths.PublicFilesURL).
func RegisterStylesRoutes ¶
func RegisterStylesRoutes(r *http.ServeMux, sc *interfaces.StylesController)
RegisterStylesRoutes registers <public files>/styles/{style}/…: a public image in an image style (StylesController.ServeStyledImage).
func RegisterTaxonomyRoutes ¶
func RegisterTaxonomyRoutes(r *http.ServeMux, store *sessions.CookieStore, tc *interfaces.TaxonomyController, rl *ratelimit.RateLimiter)
RegisterTaxonomyRoutes registers the taxonomy API. Term pages themselves are served by the catch-all route's fallback (TaxonomyController.TermPageFallback).
func RegisterUserFilesRoutes ¶
func RegisterUserFilesRoutes(r *http.ServeMux, store *sessions.CookieStore, ufc *interfaces.UserFilesController)
RegisterUserFilesRoutes registers JSON API for per-user uploads (session + CSRF on mutating requests).
func RegisterUserRoutes ¶
func RegisterUserRoutes(r *http.ServeMux, store *sessions.CookieStore, uc *interfaces.UserController, oc *interfaces.OAuthController, limits UserRateLimits)
RegisterUserRoutes registers the account routes: sign-in (with its two-factor step), sign-out, sign-up, password reset, invitations, the social sign-in (when oc is set), the profiles and their tabs, and editing and cancelling an account, rate limited by limits.
func RegisterViewCountRoutes ¶
func RegisterViewCountRoutes(r *http.ServeMux, vc *interfaces.ViewCountController, rl *ratelimit.RateLimiter)
RegisterViewCountRoutes registers POST /api/node/view, the page's report of a view of its node, limited per client by rl.
func UploadsFileServer ¶
func UploadsFileServer(store filestore.Store, storeURL func() string, cacheControl string) http.Handler
UploadsFileServer serves uploaded files from store: files only (no folder listings, no dotfiles like .htaccess), with nosniff and a sandboxing CSP; anything but images and PDF is a download. When the store serves its files itself (storeURL, e.g. a bucket's CDN), it redirects there instead.
Types ¶
type Mux ¶
type Mux interface {
Handle(pattern string, handler http.Handler)
HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}
Mux - what route registration needs from a router.
type UserRateLimits ¶
type UserRateLimits struct {
UserSearch, AuthForm, Password *ratelimit.RateLimiter
LoginAccount, ResetAddress *ratelimit.RateLimiter
}
UserRateLimits - the limiters of the account pages: per client (UserSearch, AuthForm, Password) and per account (LoginAccount - the sign-in tries at one account, whoever makes them; ResetAddress - the reset mails to one address).