INNER CODE UNIT · Go
APIHandler
simagix/hatchet · api_handler.go:15
func APIHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params) {
/** APIs
* /api/hatchet/v1.0/hatchets/{hatchet}/logs/all
* /api/hatchet/v1.0/hatchets/{hatchet}/logs/slowops
* /api/hatchet/v1.0/hatchets/{hatchet}/stats/slowops
*/
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
hatchetName := params.ByName("hatchet")
attr := params.ByName("attr")
category := params.ByName("category")
dbase, err := GetDatabase(hatchetName)
if err != nil {
json.NewEncoder(w).Encode(map[string]interface{}{"ok": 0, "error": err.Error()})
return
}
defer dbase.Close()
if dbase.GetVerbose() {