mirror of
https://github.com/Xevion/banner.git
synced 2025-12-07 07:14:25 -06:00
Add error types, small comment typo
This commit is contained in:
12
errors.go
Normal file
12
errors.go
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
type UnexpectedContentTypeError struct {
|
||||||
|
Expected string
|
||||||
|
Actual string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *UnexpectedContentTypeError) Error() string {
|
||||||
|
return fmt.Sprintf("Expected content type '%s', received '%s'", e.Expected, e.Actual)
|
||||||
|
}
|
||||||
@@ -104,8 +104,8 @@ func Nonce() string {
|
|||||||
return strconv.Itoa(int(time.Now().UnixMilli()))
|
return strconv.Itoa(int(time.Now().UnixMilli()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// doRequest performs & logs the request, logging and returning the response
|
// DoRequest performs & logs the request, logging and returning the response
|
||||||
func doRequest(req *http.Request) (*http.Response, error) {
|
func DoRequest(req *http.Request) (*http.Response, error) {
|
||||||
log.Debug().Str("method", strings.TrimRight(req.Method, " ")).Str("url", req.URL.String()).Str("query", req.URL.RawQuery).Str("content-type", req.Header.Get("Content-Type")).Msg("Request")
|
log.Debug().Str("method", strings.TrimRight(req.Method, " ")).Str("url", req.URL.String()).Str("query", req.URL.RawQuery).Str("content-type", req.Header.Get("Content-Type")).Msg("Request")
|
||||||
res, err := client.Do(req)
|
res, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user