| 39 | } |
| 40 | |
| 41 | func (s *gmailWatchServer) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 42 | handler := gmailwatch.HTTPHandler{ |
| 43 | Config: gmailwatch.HTTPConfig{ |
| 44 | Path: s.cfg.Path, |
| 45 | Account: s.cfg.Account, |
| 46 | BodyLimit: defaultPushBodyLimitBytes, |
| 47 | HasHook: s.cfg.HookURL != "", |
| 48 | AllowNoHook: s.cfg.AllowNoHook, |
| 49 | }, |
| 50 | Authorize: s.authorize, |
| 51 | Process: func(ctx context.Context, notification gmailwatch.Notification) (*gmailwatch.ProcessedPayload, error) { |
| 52 | return s.watchProcessor().Process(ctx, notification) |
| 53 | }, |
| 54 | Now: s.currentTime, |
| 55 | Warnf: s.warnf, |
| 56 | } |
| 57 | handler.ServeHTTP(w, r) |
| 58 | } |
| 59 | |
| 60 | func (s *gmailWatchServer) authorize(r *http.Request) bool { |
| 61 | authorizer := gmailwatch.Authorizer{ |