internal/api/notifications.go
internal/api · 138 lines · 13 declarations · source
Declarations
type notificationRegisterRequest
type notificationRegisterRequest struct {
URL string `json:"url"`
}
type notificationEndpointRequest
type notificationEndpointRequest struct {
ID string `json:"id"`
}
type notificationEndpointListRequest
type notificationEndpointListRequest struct{}
notificationEndpointListRequest takes nothing: the credential decides the project, as it does everywhere else on this surface.
type notificationDeliveryListRequest
type notificationDeliveryListRequest struct {
Limit int `json:"limit,omitempty"`
}
type notificationEndpointList
type notificationEndpointList struct {
Endpoints []pg.Endpoint `json:"endpoints"`
}
type notificationDeliveryList
type notificationDeliveryList struct {
Deliveries []pg.DeliveryRecord `json:"deliveries"`
}
type notificationDisabled
type notificationDisabled struct {
Disabled bool `json:"disabled"`
}
method Server.registerNotificationEndpoint
func (s *Server) registerNotificationEndpoint(w http.ResponseWriter, r *http.Request, grant credential.Grant)
registerNotificationEndpoint nominates somewhere to be told that memory formed.
The destination is checked here, when somebody types it, as well as at the moment of sending. A refusal hours later in a delivery nobody is watching is a refusal nobody reads.
method Server.listNotificationEndpoints
func (s *Server) listNotificationEndpoints(w http.ResponseWriter, r *http.Request, grant credential.Grant)
method Server.disableNotificationEndpoint
func (s *Server) disableNotificationEndpoint(w http.ResponseWriter, r *http.Request, grant credential.Grant)
method Server.listNotificationDeliveries
func (s *Server) listNotificationDeliveries(w http.ResponseWriter, r *http.Request, grant credential.Grant)
listNotificationDeliveries is how a parked delivery is found by asking rather than by grepping.
method Server.notificationsReady
func (s *Server) notificationsReady(w http.ResponseWriter) bool
notificationsReady refuses every route when the operator has named no destinations.
Refused rather than served-and-empty, because an application that registered an endpoint and got a receipt would reasonably believe it would be told, and a deployment that intends to tell nobody should say so at the first request rather than by never calling.
method Server.notificationError
func (s *Server) notificationError(w http.ResponseWriter, r *http.Request, grant credential.Grant, operation string, err error)