diff options
| author | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-10-05 14:53:37 +0200 |
|---|---|---|
| committer | Philipp Tanlak <philipp.tanlak@gmail.com> | 2023-10-05 14:53:37 +0200 |
| commit | 1fc497fbdc79a43c62ac2e8eaf4827752dbeef8e (patch) | |
| tree | 67738e213ef97f249bdfa0f1bddda0839192cb77 /utils.go | |
| parent | bd9e7f7acfd855d4685aa4544169c0e29cdbf205 (diff) | |
Refactor codebase into modules
Diffstat (limited to 'utils.go')
| -rw-r--r-- | utils.go | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -7,10 +7,11 @@ package flyscrape import ( "bytes" "encoding/json" + "net/http" "strings" ) -func PrettyPrint(v any, prefix string) string { +func Prettify(v any, prefix string) string { var buf bytes.Buffer enc := json.NewEncoder(&buf) enc.SetEscapeHTML(false) @@ -19,14 +20,8 @@ func PrettyPrint(v any, prefix string) string { return prefix + strings.TrimSuffix(buf.String(), "\n") } -func Print(v any, prefix string) string { - var buf bytes.Buffer - enc := json.NewEncoder(&buf) - enc.SetEscapeHTML(false) - enc.Encode(v) - return prefix + strings.TrimSuffix(buf.String(), "\n") -} +type RoundTripFunc func(*http.Request) (*http.Response, error) -func ParseConfig(cfg Config, v any) { - json.Unmarshal(cfg, v) +func (f RoundTripFunc) RoundTrip(r *http.Request) (*http.Response, error) { + return f(r) } |