Documentation ¶
Overview ¶
HTTP handlers.
Unless otherwise specified the following is true of all endpoints:
* No authentication required
* URLs can have embedded parameters (/users/<username>) and query parameters
* Request bodies must be JSON formatted
* Response bodies will always be JSON
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct { // Error text Error string `json:"error"` }
Error returned by the API
type GHWebhookHandler ¶
type GHWebhookHandler struct { // GH API client GH *github.Client // GHWebhookSecret is key used to sign an HMAC of GitHub webhook requests // See config.Config#GHWebhookSecret for more details. GHWebhookSecret string // MessageBus receives messages.Message items and processes them MessageBus chan messages.Message }
GHWebhookHandler receives GitHub event notifications from GitHub.
The webhook parses these events and translates them into messages.Message structs. These are then sent to a message bus and processed.
Currently only issue + pull request comments are valid message sources. Edits to comments will be ignored.
func (GHWebhookHandler) Register ¶
func (h GHWebhookHandler) Register(router *mux.Router)
Register handler at POST /github/webhook
func (GHWebhookHandler) ServeHTTP ¶
func (h GHWebhookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP parses the GitHub event sent in the request and sends messages.Messages to the MessageBus.
Responds with GHWebhookResponse.
type GHWebhookResponse ¶
type GHWebhookResponse struct { // OK indicates the webhook completed successfully OK bool `json:"ok"` // HadMessages indicates if the event sent to the webhook had any messages HadMessages bool `json:"had_messages"` }
GHWebhookResponse provides some very basic status information about what the webhook did This information is never used by the GitHub API. Instead it can be used by us to debug the webhook.
type HealthHandler ¶
type HealthHandler struct{}
HealthHandler returns if the server is functioning correctly
func (HealthHandler) Register ¶
func (h HealthHandler) Register(router *mux.Router)
Register handler at GET /health
func (HealthHandler) ServeHTTP ¶
func (h HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP responds to all requests with a HealthResponse and status HTTP 200 OK
type HealthResponse ¶
type HealthResponse struct { // OK indicates if server is working correctly OK bool `json:"ok"` }
HealthResponse holds status of server
type JSONResponder ¶
type JSONResponder struct { // Status wit h which to respond Status int // Data to write as JSON Data interface{} }
JSONResponder writes a JSON encoded object as a response
func (JSONResponder) Respond ¶
func (r JSONResponder) Respond(w http.ResponseWriter)
Respond with Status and Data JSON encoded
type PanicHandler ¶
type PanicHandler struct { // Logger used to print debug information about any panics which might occur Logger golog.Logger // Handler to run Handler http.Handler }
func (PanicHandler) ServeHTTP ¶
func (h PanicHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler
type Registerable ¶
Registerable can register itself with a router