-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ability to change log verbosity through cli / env var and also a…
…dds debug logging statements for upstream requests Signed-off-by: Alex Creasy <[email protected]>
- Loading branch information
1 parent
f9f78c3
commit 518390a
Showing
7 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ type EnvConfig struct { | |
StandaloneMode bool | ||
DevModePort int | ||
StaticAssetsDir string | ||
LogLevel string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package integrations | ||
|
||
import ( | ||
"bytes" | ||
"io" | ||
"net/http" | ||
) | ||
|
||
func StreamToString(stream io.Reader) string { | ||
if stream == nil { | ||
return "" | ||
} | ||
buf := new(bytes.Buffer) | ||
_, err := buf.ReadFrom(stream) | ||
if err != nil { | ||
return "" | ||
} | ||
return buf.String() | ||
} | ||
|
||
func CloneBody(r *http.Request) ([]byte, error) { | ||
buf, _ := io.ReadAll(r.Body) | ||
rdr1 := io.NopCloser(bytes.NewBuffer(buf)) | ||
rdr2 := io.NopCloser(bytes.NewBuffer(buf)) | ||
r.Body = rdr2 // OK since rdr2 implements the io.ReadCloser interface | ||
|
||
defer rdr1.Close() | ||
cloneBody, err := io.ReadAll(rdr2) | ||
|
||
return cloneBody, err | ||
} |