SherClockHolmes / webpush-go

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

Using fasthttp? #28

Closed marcoroganovic closed 5 years ago

marcoroganovic commented 5 years ago

Hi, is there a way to use fasthttp client with webpush-go package? I'm new to Go language, and reading source I can see that it has client option.

SherClockHolmes commented 5 years ago

Hey @marcoroganovic,

If the library does not directly implement the HTTPClient interface I would recommend wrapping the fasthttp code in a struct and passing that to the Options:

type MyFastHTPClient struct {}

func (c *MyFastHTPClient) Do(r *http.Request) (*http.Response, error) {
    // fasthttp code
}

&webpush.Options{
    Client: &MyFastHTPClient{},
}

Hopefully this helps.