notificationsapp: Index | Files | Directories

package notificationsapp

import ""

Package notificationsapp is a web frontend for a notifications service.

Note, the canonical issue tracker for this package is currently hosted at Its notifications are implemented using this very package.


Package Files

doc.go main.go


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.

func New Uses

func New(service notifications.Service, opt Options) http.Handler

New returns a notifications app http.Handler using given services and options.

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))

type Options Uses

type Options struct {
    HeadPre template.HTML
    BodyPre template.HTML

    // BodyTop provides components to include on top of <body> of page rendered for req. It can be nil.
    BodyTop func(req *http.Request) ([]htmlg.Component, error)


assetsPackage assets contains assets for notificationsapp.
httpclientPackage httpclient contains notifications.Service implementation over HTTP.
httphandlerPackage httphandler contains an API handler for notifications.Service.
httproutePackage httproute contains route paths for httpclient, httphandler.

Package notificationsapp imports 12 packages (graph) and is imported by 1 packages. Updated 2017-04-23. Refresh now. Tools for package owners.