Apply suggestions from code review
License: MIT Signed-off-by: Ian Preston <ianopolous@protonmail.com> Co-Authored-By: ianopolous <ianopolous@protonmail.com>
Hector Sanjuan committed
Nov 15, 2018 at 21:13 UTC
3b2ce4a85daef99c0fd56173316950b82b9d147b
2 files changed
+4
-4
core/corehttp/proxy.go
+3
-3
@@ -21,7 +21,7 @@ func ProxyOption() ServeOption {
21
// parse request
22
parsedRequest, err := parseRequest(request)
23
if err != nil {
24
- handleError(w, "Failed to parse request", err, 400)
24
+ handleError(w, "failed to parse request", err, 400)
25
return
26
}
27
@@ -29,7 +29,7 @@ func ProxyOption() ServeOption {
29
request.URL.Path = parsedRequest.httpPath
30
target, err := url.Parse(fmt.Sprintf("libp2p://%s", parsedRequest.target))
31
if err != nil {
32
- handleError(w, "Failed to parse url", err, 400)
32
+ handleError(w, "failed to parse url", err, 400)
33
return
34
}
35
@@ -75,5 +75,5 @@ func parseRequest(request *http.Request) (*proxyRequest, error) {
75
func handleError(w http.ResponseWriter, msg string, err error, code int) {
76
w.WriteHeader(code)
77
fmt.Fprintf(w, "%s: %s\n", msg, err)
78
- log.Warningf("server error: %s: %s", err)
78
+ log.Warningf("http proxy error: %s: %s", err)
79
}
core/corehttp/proxy_test.go
+1
-1
@@ -14,7 +14,7 @@ func TestParseRequest(t *testing.T) {
14
15
parsed, err := parseRequest(req)
16
if err != nil {
17
- t.Error(err)
17
+ t.Fatal(err)
18
}
19
assert.True(parsed.httpPath == "path/to/index.txt", t, "proxy request path")
20
assert.True(parsed.name == "/http", t, "proxy request name")