thecodingmachine / gotenberg-go-client

Go client for the Gotenberg API
MIT License
57 stars 33 forks source link

Please use http client with timeouts #11

Closed Dysar closed 4 years ago

Dysar commented 4 years ago

Expected Behavior

When I execute Client's Post() method I want to be sure that it will not hang forever.

Current Behavior

Currently there is no limit

Possible Solution

Using http client as described in this article solves this issue https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779

gulien commented 4 years ago

Hello @Dysar indeed I should allow to set a "custom" http client.

Something like:

type Client struct {
    Hostname string
        HttpClient *http.Client
}
Dysar commented 4 years ago

Yeeeah, that would be a good solution!

gulien commented 4 years ago

I did like it in the PHP client: https://github.com/thecodingmachine/gotenberg-php-client/blob/master/src/Client.php#L27

Dunno why I forgot to do it in the Go clien too 😄