Commit 3b2ce4a8 authored by Hector Sanjuan's avatar Hector Sanjuan Committed by Steven Allen

Apply suggestions from code review

License: MIT
Signed-off-by: default avatarIan Preston <ianopolous@protonmail.com>
Co-Authored-By: default avatarianopolous <ianopolous@protonmail.com>
parent bf184376
......@@ -21,7 +21,7 @@ func ProxyOption() ServeOption {
// parse request
parsedRequest, err := parseRequest(request)
if err != nil {
handleError(w, "Failed to parse request", err, 400)
handleError(w, "failed to parse request", err, 400)
return
}
......@@ -29,7 +29,7 @@ func ProxyOption() ServeOption {
request.URL.Path = parsedRequest.httpPath
target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target))
if err != nil {
handleError(w, "Failed to parse url", err, 400)
handleError(w, "failed to parse url", err, 400)
return
}
......@@ -75,5 +75,5 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
func handleError(w http.ResponseWriter, msg string, err error, code int) {
w.WriteHeader(code)
fmt.Fprintf(w, "%s: %s\n", msg, err)
log.Warningf("server error: %s: %s", err)
log.Warningf("http proxy error: %s: %s", err)
}
......@@ -14,7 +14,7 @@ func TestParseRequest(t *testing.T) {
parsed, err := parseRequest(req)
if err != nil {
t.Error(err)
t.Fatal(err)
}
assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path")
assert.True(parsed.name == "/http", t, "proxy request name")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment