Skip to content

Commit

Permalink
Improve debugging (#8)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha authored Jan 13, 2023
1 parent 79d3840 commit 5b99ac9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions pkg/cmds/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewCmdRun(ctx context.Context) *cobra.Command {
var (
addr = ":8000"
metricsAddr = ":8080"
apiServerAddress = "appcode.ninja"
apiServerAddress = ""
debug = false
)
cmd := &cobra.Command{
Expand Down Expand Up @@ -172,6 +172,13 @@ type cloudflareTransport struct {
}

func (rt cloudflareTransport) RoundTrip(req *http.Request) (*http.Response, error) {
if rt.debug {
if data, err := httputil.DumpRequestOut(req, true); err == nil {
fmt.Println("REQUEST: >>>>>>>>>>>>>>>>>>>>>>>")
fmt.Println(string(data))
}
}

meta, err := rt.check(req)
if err != nil {
cr := cloudflare.Response{
Expand All @@ -182,6 +189,10 @@ func (rt cloudflareTransport) RoundTrip(req *http.Request) (*http.Response, erro
if err != nil {
return nil, err
}
if rt.debug {
fmt.Println("RESPONSE_403: >>>>>>>>>>>>>>>>>>>>>>>")
fmt.Println(string(data))
}
return &http.Response{
StatusCode: http.StatusForbidden,
Body: io.NopCloser(bytes.NewReader(data)),
Expand All @@ -193,12 +204,8 @@ func (rt cloudflareTransport) RoundTrip(req *http.Request) (*http.Response, erro
if err != nil {
return nil, err
}
fmt.Println("INSTALLER_METADATA: >>>>>>>>>>>>>>>>>>>>>>>")
fmt.Println(string(md))

if data, err := httputil.DumpRequestOut(req, true); err == nil {
fmt.Println("REQUEST: >>>>>>>>>>>>>>>>>>>>>>>")
fmt.Println(string(data))
}
}

req.Host = ""
Expand Down

0 comments on commit 5b99ac9

Please sign in to comment.