Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ func (srv *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(srv.Ver))
return
case ".well-known":
srv.serveStaticRoute(w, r)
return
if srv.serveStaticRoute(w, r) {
return
}
case "restconf":
op2, p := shift(p, '/')
r.URL = p
Expand Down
8 changes: 7 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package restconf
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -76,7 +77,12 @@ func handleErr(compliance ComplianceOptions, err error, r *http.Request, w http.
}
fc.Debug.Printf("web request error [%s] %s %s", r.Method, r.URL, err.Error())
msg := err.Error()
code := fc.HttpStatusCode(err)
var code int
if errors.Is(err, ErrBadAddress) {
code = 400
} else {
code = fc.HttpStatusCode(err)
}
if !compliance.SimpleErrorResponse {
errResp := errResponse{
Type: "protocol",
Expand Down