{"record":{"id":"e8fbf194d8a29b47","repo":"AlexxIT/go2rtc","slug":"method-not-allowed","errorCode":null,"errorMessage":"Method not allowed","messagePattern":"Method not allowed","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/api/api.go","lineNumber":291,"sourceCode":"\t\treturn\n\t}\n\n\tlog.Debug().Msgf(\"[api] restart %s\", path)\n\n\tgo syscall.Exec(path, os.Args, os.Environ())\n}\n\nfunc logHandler(w http.ResponseWriter, r *http.Request) {\n\tswitch r.Method {\n\tcase \"GET\":\n\t\t// Send current state of the log file immediately\n\t\tw.Header().Set(\"Content-Type\", \"application/jsonlines\")\n\t\t_, _ = app.MemoryLog.WriteTo(w)\n\tcase \"DELETE\":\n\t\tapp.MemoryLog.Reset()\n\t\tResponse(w, \"OK\", \"text/plain\")\n\tdefault:\n\t\thttp.Error(w, \"Method not allowed\", http.StatusBadRequest)\n\t}\n}\n\ntype Source struct {\n\tID       string `json:\"id,omitempty\"`\n\tName     string `json:\"name,omitempty\"`\n\tInfo     string `json:\"info,omitempty\"`\n\tURL      string `json:\"url,omitempty\"`\n\tLocation string `json:\"location,omitempty\"`\n}\n\nfunc ResponseSources(w http.ResponseWriter, sources []*Source) {\n\tif len(sources) == 0 {\n\t\thttp.Error(w, \"no sources\", http.StatusNotFound)\n\t\treturn\n\t}\n\n\tvar response = struct {","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/api/api.go#L273-L309","documentation":"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.","triggerScenarios":"Sending POST/PUT/HEAD or other methods to /api/log.","commonSituations":"Automation scripts using POST to push logs, or probing the endpoint with the wrong verb.","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"],"exampleFix":"// before\ncurl -X POST http://host:1984/api/log\n// after\ncurl http://host:1984/api/log        # read\ncurl -X DELETE http://host:1984/api/log  # clear","handlingStrategy":"validation","validationCode":"if (method !== 'GET' && method !== 'DELETE') throw new Error('/api/log supports GET and DELETE only');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use GET to read and DELETE to clear /api/log","Never POST/PUT to the log endpoint"],"tags":["http","api","method","bad-request"],"backgroundTag":"method-not-allowed","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}