Documentation
¶
Overview ¶
Package webpushtest is an in-process push service for tests and the demo: it answers the requests FCM, Mozilla's autopush, Apple and Windows would get, checks the VAPID token as they do, decrypts the payload when it made the subscription, and records every message. Nothing it's given ever reaches the network.
Index ¶
- Variables
- type Page
- type Received
- type Service
- func (s *Service) Answer(endpoint string, status int)
- func (s *Service) Client() *http.Client
- func (s *Service) Received() []Received
- func (s *Service) Reset()
- func (s *Service) Serve(u string, p Page)
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Service) Subscribe(browser string) (endpoint, p256dh, auth string)
Constants ¶
This section is empty.
Variables ¶
var Hosts = map[string]string{
"chrome": "https://fcm.googleapis.com/fcm/send/",
"android": "https://fcm.googleapis.com/fcm/send/",
"edge": "https://wns2-bl2p.notify.windows.com/w/?token=",
"firefox": "https://updates.push.services.mozilla.com/wpush/v2/",
"safari": "https://web.push.apple.com/",
"ios": "https://web.push.apple.com/",
}
Hosts are the push services' hosts, by browser.
Functions ¶
This section is empty.
Types ¶
type Page ¶
Page is what the service answers a GET with, as the web server of a site would: a site's hosted service worker, the page a link opens.
type Received ¶
type Received struct {
At time.Time
Endpoint string
Header http.Header
Body []byte
// Claims are the VAPID token's claims; Key the public key that signed it.
Claims webpush.Claims
Key []byte
// Payload is the decrypted message, for subscriptions this service made.
Payload []byte
// Status is what the service answered.
Status int
}
Received is one message the service got.
type Service ¶
type Service struct {
// Now is the clock tokens are checked against.
Now func() time.Time
// contains filtered or unexported fields
}
Service is the fake push service.
func (*Service) Answer ¶
Answer makes the service answer status for an endpoint from now on: 410 for a subscription that ended, 429 or 503 for a busy service.
func (*Service) Serve ¶
Serve makes GET requests for u answer p (any other GET answers 404), so tests check sites and links without the network.