Documentation ¶
Overview ¶
Package issuesapp is a web frontend for an issues service.
Note, the canonical issue tracker for this package is currently hosted at https://dmitri.shuralyov.com/issues/github.com/shurcooL/issuesapp. It is 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.
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.
Functions ¶
func New ¶
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))
Types ¶
type Options ¶
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) // SignIn returns HTML with a link or button to sign in. It can be nil. SignIn func(returnURL string) template.HTML }
Options for configuring issues app.
Directories ¶
Path | Synopsis |
---|---|
Package assets contains assets for issuesapp.
|
Package assets contains assets for issuesapp. |
cmd
|
|
githubissues
githubissues is a simple test program for issuesapp that uses GitHub API-backed services.
|
githubissues is a simple test program for issuesapp that uses GitHub API-backed services. |
Package common contains common code for backend and frontend.
|
Package common contains common code for backend and frontend. |
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 issuesapp.
|
frontend script for issuesapp. |
Package httpclient contains issues.Service implementation over HTTP.
|
Package httpclient contains issues.Service implementation over HTTP. |
Package httphandler contains an API handler for issues.Service.
|
Package httphandler contains an API handler for issues.Service. |
Package httproute contains route paths for httpclient, httphandler.
|
Package httproute contains route paths for httpclient, httphandler. |