add loggin switch

This commit is contained in:
Gianni Carafa
2023-11-02 22:59:07 +01:00
parent 63dcaeba3c
commit 7ae1a29932
2 changed files with 5 additions and 1 deletions

View File

@@ -72,3 +72,4 @@ http://localhost:8080/raw/https://www.google.com
| `USER_AGENT` | User agent to emulate | `Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)` | | `USER_AGENT` | User agent to emulate | `Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)` |
| `X_FORWARDED_FOR` | IP Forwarder address | `66.249.66.1` | | `X_FORWARDED_FOR` | IP Forwarder address | `66.249.66.1` |
| `USERPASS` | Enables Basic Auth, format `admin:123456` | | | `USERPASS` | Enables Basic Auth, format `admin:123456` | |
| `LOG_URLS` | Log fetched URL's | `true` |

View File

@@ -41,13 +41,16 @@ func fetchSite(urlpath string, queries map[string]string) (string, *http.Request
} }
} }
urlQuery = strings.TrimSuffix(urlQuery, "&") urlQuery = strings.TrimSuffix(urlQuery, "&")
urlQuery = strings.TrimSuffix(urlQuery, "?")
u, err := url.Parse(urlpath) u, err := url.Parse(urlpath)
if err != nil { if err != nil {
return "", nil, nil, err return "", nil, nil, err
} }
if os.Getenv("LOG_URLS ") == "" || os.Getenv("NOLOGS") == "true" {
log.Println(u.String() + urlQuery) log.Println(u.String() + urlQuery)
}
// Fetch the site // Fetch the site
client := &http.Client{} client := &http.Client{}