Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added admin features #64

Merged
merged 11 commits into from
Dec 26, 2019
Prev Previous commit
Next Next commit
Base64 encode request/response for socket transfer
  • Loading branch information
antoniomika committed Dec 24, 2019
commit 8466ab5f3f23553c893900c7263060f18dee35e3
5 changes: 3 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"compress/gzip"
"crypto/tls"
"encoding/base64"
"encoding/json"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -222,11 +223,11 @@ func startHTTPHandler(state *State) {
"requestMethod": c.Request.Method,
"requestUrl": c.Request.URL,
"requestHeaders": requestHeaders,
"requestBody": string(reqBody),
"requestBody": base64.StdEncoding.EncodeToString(reqBody),
"responseHeaders": response.Header,
"responseCode": response.StatusCode,
"responseStatus": response.Status,
"responseBody": string(resBody),
"responseBody": base64.StdEncoding.EncodeToString(resBody),
})

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions templates/console.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@

if ("Content-Type" in requestData.requestHeaders && requestData.requestHeaders["Content-Type"][0] == "application/json") {
$("#requestBody").html(`
<pre><code>${JSON.stringify(JSON.parse(requestData.requestBody), null, 4)}</code></pre>
<pre><code>${JSON.stringify(JSON.parse(atob(requestData.requestBody)), null, 4)}</code></pre>
`);
} else {
$("#requestBody").html(`
<pre><code>${requestData.requestBody}</code></pre>
<pre><code>${atob(requestData.requestBody)}</code></pre>
`);
}

Expand All @@ -93,11 +93,11 @@

if ("Content-Type" in requestData.responseHeaders && requestData.responseHeaders["Content-Type"][0] == "application/json") {
$("#responseBody").html(`
<pre><code>${JSON.stringify(JSON.parse(requestData.responseBody), null, 4)}</code></pre>
<pre><code>${JSON.stringify(JSON.parse(atob(requestData.responseBody)), null, 4)}</code></pre>
`);
} else {
$("#responseBody").html(`
<pre><code>${requestData.responseBody}</code></pre>
<pre><code>${atob(requestData.responseBody)}</code></pre>
`);
}

Expand Down