Documentation ¶
Overview ¶
Package client provides a HTTP client implementation. This client is opinionated and comes with good defaults.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Safe ¶ added in v0.0.8
Safe creates a http client that has some good defaults & is safe from server-side request forgery (SSRF). It also logs requests and responses using log.Logger
Example ¶
package main import ( "os" "github.com/komuw/ong/client" "github.com/komuw/ong/log" ) func main() { l := log.New(os.Stdout, 7) cli := client.Safe(l) // This is the AWS metadata url. url := "http://169.254.169.254/latest/meta-data" _, _ = cli.Get(url) // This will log something like: // {"durationMS":0,"err":"dial tcp 169.254.169.254:80: ong/client: address 169.254.169.254 IsLinkLocalUnicast","level":"error","logID":"yHSDRXAJP7QKx3AJQKNt7w","method":"GET","msg":"http_client","pid":325431,"timestamp":"2022-12-08T08:43:42.151691969Z","url":"http://169.254.169.254/latest/meta-data"} }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.