mirror of
https://github.com/Xevion/banner.git
synced 2025-12-06 13:14:25 -06:00
Continue improving comments & use of structured logs
This commit is contained in:
@@ -42,9 +42,9 @@ func AddUserAgent(req *http.Request) {
|
||||
req.Header.Add("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36")
|
||||
}
|
||||
|
||||
func ContainsContentType(header string, search string) bool {
|
||||
func ContainsContentType(response *http.Response, search string) bool {
|
||||
// Split on commas, check if any of the types match
|
||||
for _, content_type := range strings.Split(header, ";") {
|
||||
for _, content_type := range strings.Split(response.Header.Get("Content-Type"), ";") {
|
||||
if content_type == search {
|
||||
return true
|
||||
}
|
||||
@@ -67,8 +67,9 @@ func Nonce() string {
|
||||
return strconv.Itoa(int(time.Now().UnixMilli()))
|
||||
}
|
||||
|
||||
// doRequest performs & logs the request, logging and returning the response
|
||||
func doRequest(req *http.Request) (*http.Response, error) {
|
||||
log.Debug().Str("method", req.Method).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)
|
||||
if err != nil {
|
||||
log.Err(err).Str("method", req.Method).Msg("Request Failed")
|
||||
|
||||
Reference in New Issue
Block a user