issuesapp: Index | Files | Directories

package issuesapp

import ""

Package issuesapp is a web frontend for an issues service.

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


Package Files

display.go doc.go errorhandler.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.

var RepoSpecContextKey = &contextKey{"RepoSpec"}

RepoSpecContextKey is a context key for the request's repository specification. That value specifies which repo the issues are to be displayed for. The associated value will be of type issues.RepoSpec.

var StateContextKey = &contextKey{"State"}

StateContextKey is a context key for the request's common state. That value specifies the common state of the page being rendered. The associated value will be of type common.State.

func New Uses

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

New returns an issues app http.Handler using given services and options. If usersService is nil, then there is no way to have an authenticated user. Emojis image data is expected to be available at /emojis/emojis.png, unless opt.DisableReactions is true.

In order to serve HTTP requests, the returned http.Handler expects each incoming request to have 2 parameters provided to it via RepoSpecContextKey and BaseURIContextKey context keys. For example:

issuesApp := issuesapp.New(...)

http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
	req = req.WithContext(context.WithValue(req.Context(), issuesapp.RepoSpecContextKey, issues.RepoSpec{...}))
	req = req.WithContext(context.WithValue(req.Context(), issuesapp.BaseURIContextKey, string(...)))
	issuesApp.ServeHTTP(w, req)

An HTTP API must be available (currently, only EditComment endpoint is used):

// Register HTTP API endpoints.
apiHandler := httphandler.Issues{Issues: service}
http.Handle(httproute.List, errorHandler(apiHandler.List))
http.Handle(httproute.Count, errorHandler(apiHandler.Count))
http.Handle(httproute.ListComments, errorHandler(apiHandler.ListComments))
http.Handle(httproute.ListEvents, errorHandler(apiHandler.ListEvents))
http.Handle(httproute.EditComment, errorHandler(apiHandler.EditComment))

type Options Uses

type Options struct {
    Notifications    notifications.Service // If not nil, issues containing unread notifications are highlighted.
    DisableReactions bool                  // Disable all support for displaying and toggling reactions.

    HeadPre, HeadPost template.HTML
    BodyPre           string // An html/template definition of "body-pre" template.

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

Options for configuring issues app.


assetsPackage assets contains assets for issuesapp.
cmd/asanaissuesasanaissues is a simple test program for issuesapp that uses Asana API-backed services.
cmd/githubissuesgithubissues is a simple test program for issuesapp that uses GitHub API-backed services.
commonPackage common contains common code for backend and frontend.
componentPackage component contains individual components that can render themselves as HTML.
frontendfrontend script for issuesapp.
httpclientPackage httpclient contains issues.Service implementation over HTTP.
httphandlerPackage httphandler contains an API handler for issues.Service.
httproutePackage httproute contains route paths for httpclient, httphandler.

Package issuesapp imports 31 packages (graph) and is imported by 6 packages. Updated 2019-03-18. Refresh now. Tools for package owners.