diff options
author | Andinus <andinus@nand.sh> | 2021-04-13 13:52:09 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2021-04-13 13:52:09 +0530 |
commit | 863b5301e2d2c75683086a608ebdf8f497133b94 (patch) | |
tree | fc7a07bac513abbd874102fa2e95b9dd0b00d415 /hibp/req.go | |
parent | 12fdf3632824a3ffea9f8dfc9249cb7a27e6a2c8 (diff) | |
download | orion-863b5301e2d2c75683086a608ebdf8f497133b94.tar.gz |
Re-initialize project for Raku port
Diffstat (limited to 'hibp/req.go')
-rw-r--r-- | hibp/req.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/hibp/req.go b/hibp/req.go deleted file mode 100644 index 8081d3c..0000000 --- a/hibp/req.go +++ /dev/null @@ -1,56 +0,0 @@ -package hibp - -import ( - "fmt" - "io/ioutil" - "net/http" - "time" -) - -func reqHIBP(reqApi string) (body string, err error) { - c := http.Client{ - // TODO: timeout should be configurable by the user - Timeout: time.Second * 64, - } - - req, err := http.NewRequest(http.MethodGet, reqApi, nil) - if err != nil { - err = fmt.Errorf("hibp/req.go: Failed to create request\n%s", - err.Error()) - return - } - - // User-Agent should be passed with every request to - // make work easier for the server handler. Include contact - // information along with the project name so they could reach - // you if required. - req.Header.Set("User-Agent", - "Andinus / Orion - https://andinus.nand.sh/orion") - - res, err := c.Do(req) - if err != nil { - err = fmt.Errorf("hibp/req.go: Failed to get response\n%s", - err.Error()) - return - } - defer res.Body.Close() - - if res.StatusCode != 200 { - fmt.Errorf("hibp/req.go: Unexpected response status code received: %d %s", - res.StatusCode, - http.StatusText(res.StatusCode)) - return - } - - // This will read everything to memory and is okay to use here - // because the response is expected to be small. - out, err := ioutil.ReadAll(res.Body) - if err != nil { - fmt.Errorf("hibp/req.go: Failed to read res.Body\n%s", - err.Error()) - return - } - - body = string(out) - return -} |