Documentation ¶
Overview ¶
Package notificationsapp is a web frontend for a notifications service.
Note, the canonical issue tracker for this package is currently hosted at https://dmitri.shuralyov.com/issues/github.com/shurcooL/notificationsapp. Its notifications are implemented using this very package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BaseURIContextKey = &contextKey{"BaseURI"}
BaseURIContextKey is a context key for the request's base URI. That value specifies the base URI prefix to use for all absolute URLs. The associated value will be of type string.
Functions ¶
func New ¶
New returns a notifications app http.Handler using given services and options. It uses users service, if not nil, when displaying errors (admins see full details).
In order to serve HTTP requests, the returned http.Handler expects each incoming request to have a parameter provided to it via BaseURIContextKey context key. For example:
notificationsApp := notificationsapp.New(...) http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { req = req.WithContext(context.WithValue(req.Context(), notificationsapp.BaseURIContextKey, string(...))) notificationsApp.ServeHTTP(w, req) })
An HTTP API must be available:
// Register HTTP API endpoints. apiHandler := httphandler.Notifications{Notifications: service} http.Handle(httproute.MarkRead, errorHandler(apiHandler.MarkRead)) http.Handle(httproute.MarkAllRead, errorHandler(apiHandler.MarkAllRead))
Types ¶
Directories ¶
Path | Synopsis |
---|---|
Package assets contains assets for notificationsapp.
|
Package assets contains assets for notificationsapp. |
Package component contains individual components that can render themselves as HTML.
|
Package component contains individual components that can render themselves as HTML. |
frontend script for notificationsapp.
|
frontend script for notificationsapp. |
Package httpclient contains notifications.Service implementation over HTTP.
|
Package httpclient contains notifications.Service implementation over HTTP. |
Package httphandler contains an API handler for notifications.Service.
|
Package httphandler contains an API handler for notifications.Service. |
Package httproute contains route paths for httpclient, httphandler.
|
Package httproute contains route paths for httpclient, httphandler. |