demo
This commit is contained in:
@@ -54,6 +54,7 @@ func (o *LokiController) GetLogs() {
|
||||
}
|
||||
path += "?query={" + strings.Join(query, ", ") + "}&start=" + start + "&end=" + end
|
||||
resp, err := http.Get(config.GetConfig().LokiUrl + path) // CALL
|
||||
fmt.Println(resp, path)
|
||||
if err != nil {
|
||||
o.Ctx.ResponseWriter.WriteHeader(422)
|
||||
o.Data["json"] = map[string]string{"error": err.Error()}
|
||||
@@ -62,7 +63,16 @@ func (o *LokiController) GetLogs() {
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
o.Data["json"] = body
|
||||
var result map[string]interface{}
|
||||
// Unmarshal: string → []byte → object
|
||||
err = json.Unmarshal(body, &result)
|
||||
if err != nil {
|
||||
o.Ctx.ResponseWriter.WriteHeader(403)
|
||||
o.Data["json"] = map[string]string{"error": err.Error()}
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
o.Data["json"] = result
|
||||
o.ServeJSON()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user