SherClockHolmes / webpush-go

Web Push API Encryption with VAPID support.
MIT License
312 stars 67 forks source link

Should non 201 responses be errors? #5

Closed gauntface closed 6 years ago

gauntface commented 6 years ago

Web push protocol dictates that a web push service must return a "201" status code to indicate a successful push.

At the moment the response is returned regardless of status code, should the library check the status code and throw if the response is invalid?

SherClockHolmes commented 6 years ago

@gauntface If 201s are the only acceptable status code, I am open to suggestions on changing the method signature. Maybe something like (ok bool, err error) instead, what do other libraries do?

func SendNotification(message []byte, s *Subscription, options *Options) (ok bool, err error) { }
gauntface commented 6 years ago

Ignore me. Looks like only the node version is error'ing on non-201 response (i.e. most libraries are expecting developers to check the status code.