Skip to content

Commit 0f09505

Browse files
committed
Modify routing error messages
1 parent aa77dcc commit 0f09505

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

target/route.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"github.com/1f349/violet/logger"
66
"github.com/1f349/violet/proxy"
77
"github.com/1f349/violet/utils"
8-
"github.com/google/uuid"
98
websocket2 "github.com/gorilla/websocket"
109
"github.com/rs/cors"
1110
"golang.org/x/net/http/httpguts"
@@ -130,8 +129,7 @@ func (r Route) internalServeHTTP(rw http.ResponseWriter, req *http.Request) {
130129
// create the internal request
131130
req2, err := http.NewRequest(req.Method, u.String(), req.Body)
132131
if err != nil {
133-
Logger.Warn("Error generating new request", "err", err)
134-
utils.RespondVioletError(rw, http.StatusBadGateway, "error generating new request")
132+
utils.RespondVioletError(rw, http.StatusBadGateway, "Invalid request for proxy")
135133
return
136134
}
137135

@@ -182,7 +180,7 @@ func (r Route) internalServeHTTP(rw http.ResponseWriter, req *http.Request) {
182180
}
183181
if err != nil {
184182
Logger.Warn("Error receiving internal round trip response", "route src", r.Src, "url", req2.URL.String(), "err", err)
185-
utils.RespondVioletError(rw, http.StatusBadGateway, "error receiving internal round trip response")
183+
utils.RespondVioletError(rw, http.StatusBadGateway, "Error receiving internal round trip response")
186184
return
187185
}
188186

@@ -192,9 +190,8 @@ func (r Route) internalServeHTTP(rw http.ResponseWriter, req *http.Request) {
192190
}
193191

194192
if resp.StatusCode == http.StatusLoopDetected {
195-
u := uuid.New()
196-
Logger.Warn("Loop Detected", "id", u, "method", req.Method, "url", req.URL, "url2", req2.URL.String())
197-
utils.RespondVioletError(rw, http.StatusLoopDetected, "error loop detected: "+u.String())
193+
Logger.Warn("Loop Detected", "method", req.Method, "url", req.URL, "url2", req2.URL.String())
194+
utils.RespondVioletError(rw, http.StatusLoopDetected, "Error loop detected")
198195
return
199196
}
200197

@@ -225,7 +222,7 @@ func (r Route) internalReverseProxyMeta(rw http.ResponseWriter, req, req2 *http.
225222

226223
reqUpType := upgradeType(req2.Header)
227224
if !asciiIsPrint(reqUpType) {
228-
utils.RespondVioletError(rw, http.StatusBadRequest, fmt.Sprintf("client tried to switch to invalid protocol %q", reqUpType))
225+
utils.RespondVioletError(rw, http.StatusBadRequest, fmt.Sprintf("Invalid protocol %s", reqUpType))
229226
return true
230227
}
231228
removeHopByHopHeaders(req2.Header)

0 commit comments

Comments
 (0)