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 ( "context" "os" "github.com/komuw/ong/client" "github.com/komuw/ong/log" ) func main() { l := log.New(os.Stdout, 7)(context.Background()) 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: // {"time":"2023-02-03T18:54:13.300137216Z","level":"ERROR","source":"client.go:108","msg":"http_client","err":"dial tcp 169.254.169.254:80: ong/client: address 169.254.169.254 IsLinkLocalUnicast","method":"GET","url":"http://169.254.169.254/latest/meta-data","durationMS":0,"logID":"DYGY3eedgARMAyXZ"} }
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.