From 1fc497fbdc79a43c62ac2e8eaf4827752dbeef8e Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Thu, 5 Oct 2023 14:53:37 +0200 Subject: Refactor codebase into modules --- utils.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'utils.go') diff --git a/utils.go b/utils.go index 73efa4a..faa4937 100644 --- a/utils.go +++ b/utils.go @@ -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) } -- cgit v1.2.3