SherClockHolmes / webpush-go

Web Push API Encryption with VAPID support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should non 201 responses be errors?

gauntface opened this issue · comments

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?

@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) { }

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.