refactor(api): switch to header-based auth for GET requests

- Replace body parsing with header validation for GET endpoints
- Update router to properly handle GET vs POST requests
- Add new ValidateRequestWithHeader function
- Update README to document header requirements
This commit is contained in:
2026-02-27 23:17:18 +08:00
parent 7f54e17bf4
commit 3285e9026a
4 changed files with 69 additions and 24 deletions
+1 -8
View File
@@ -433,14 +433,7 @@ func ListInstancesHandler(w http.ResponseWriter, r *http.Request) {
return
}
body, err := io.ReadAll(r.Body)
if err != nil {
SendErrorResponse(w, http.StatusBadRequest, "failed to read request body")
return
}
defer r.Body.Close()
userID, _, err := ValidateRequestWithBody(w, r, body)
userID, _, err := ValidateRequestWithHeader(w, r)
if err != nil {
SendErrorResponse(w, http.StatusUnauthorized, err.Error())
return