Documentation
¶
Overview ¶
Package server provides HTTP routes and webhook handlers.
Index ¶
- func NewHTTPServer(addr string, s *Server) *http.Server
- func ServeInBackground(ctx context.Context, name string, srv *http.Server, exit func(code int))
- func ShutdownServers(ctx context.Context, servers ...*http.Server) error
- func StartMetricsServer(ctx context.Context, addr string, handler http.Handler, exit func(code int)) *http.Server
- type Option
- type Recorder
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHTTPServer ¶ added in v0.30.0
NewHTTPServer returns the HTTP server of s on addr. When its shutdown starts, s's waits end at once (Server.EndWaits), so that shutdown does not wait for their long polls.
func ServeInBackground ¶ added in v0.30.0
ServeInBackground runs srv.ListenAndServe in the background, logging it as name, and calls exit(1) from that goroutine when it fails for any reason but shutdown. The process passes os.Exit.
func ShutdownServers ¶ added in v0.30.0
ShutdownServers shuts every non-nil server down concurrently, within ctx, and returns their joined errors.
Types ¶
type Option ¶
type Option func(*Server)
Option configures a Server built by NewServer.
func WithMetrics ¶
WithMetrics records webhook deliveries in m. A nil m leaves the default, which records nothing.
func WithPreviewTTL ¶ added in v0.26.0
WithPreviewTTL sets the TTL of the in-server sweep, which a preview's expiresAt adds to its updatedAt; 0, the default, omits expiresAt.
func WithReadToken ¶ added in v0.26.0
WithReadToken enables the GET /v1 routes with the Bearer token, besides the deploy token. An empty token leaves them to the deploy token alone.
func WithStatusToken ¶ added in v0.30.0
WithStatusToken enables POST /webhooks/status, authenticated by the Bearer token; an empty token leaves the route unregistered.
type Recorder ¶ added in v0.30.0
type Recorder interface {
WebhookDelivery(event, status string)
}
Recorder records the webhook deliveries the server answers. *metrics.Metrics implements it.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer( a *app.App, f forge.Forge, webhooks forge.WebhookParser, deployToken string, opts ...Option, ) *Server
NewServer returns the server of the webhooks webhooks parses, over the application services a (non-nil) and the forge f, configured by opts. The deploy API is served only when deployToken is set, and the read API when deployToken or the read token is.