AlexxIT/go2rtc · warning
Method not allowed
Error message
Method not allowed
What it means
logHandler only supports GET (read memory log) and DELETE (reset it); any other HTTP method reaches the default branch and is rejected with 400. A generic method-validation guard on the /api/log endpoint.
Solutions
- Use GET /api/log to read the log
- Use DELETE /api/log to clear it
- Fix the HTTP method in your script/client configuration
Example fix
// before curl -X POST http://host:1984/api/log // after curl http://host:1984/api/log # read curl -X DELETE http://host:1984/api/log # clear
Defensive patterns
Strategy: validation
Validate before calling
if (method !== 'GET' && method !== 'DELETE') throw new Error('/api/log supports GET and DELETE only'); Prevention
- Use GET to read and DELETE to clear /api/log
- Never POST/PUT to the log endpoint
When it happens
Trigger: Sending POST/PUT/HEAD or other methods to /api/log.
Common situations: Automation scripts using POST to push logs, or probing the endpoint with the wrong verb.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/e8fbf194d8a29b47.
Report an issue: GitHub.
Appendix: source
Thrown at internal/api/api.go:291
return
}
log.Debug().Msgf("[api] restart %s", path)
go syscall.Exec(path, os.Args, os.Environ())
}
func logHandler(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "GET":
// Send current state of the log file immediately
w.Header().Set("Content-Type", "application/jsonlines")
_, _ = app.MemoryLog.WriteTo(w)
case "DELETE":
app.MemoryLog.Reset()
Response(w, "OK", "text/plain")
default:
http.Error(w, "Method not allowed", http.StatusBadRequest)
}
}
type Source struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Info string `json:"info,omitempty"`
URL string `json:"url,omitempty"`
Location string `json:"location,omitempty"`
}
func ResponseSources(w http.ResponseWriter, sources []*Source) {
if len(sources) == 0 {
http.Error(w, "no sources", http.StatusNotFound)
return
}
var response = struct {View on GitHub (pinned to c245815e75)