Commit 3e88dfb8 authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'ab_Fix_StatsForFastHTTP' into 'devbranch'

Fix: Response for mql/state was invalid json.

See merge request !92
parents d5a248a7 4ecfd3ab
Branches
Tags
1 merge request!92Fix: Response for mql/state was invalid json.
Showing with 11 additions and 1 deletion
......@@ -3,6 +3,9 @@
package statemdl
import (
"encoding/json"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
routing "github.com/qiangxue/fasthttp-routing"
)
......@@ -11,7 +14,14 @@ func StateHandler(c *routing.Context) error {
clientReponseMutex.Lock()
defer clientReponseMutex.Unlock()
c.Response.Header.Set("Access-Control-Allow-Origin", "*")
c.WriteData(clientResponseData)
ba, err := json.Marshal(clientResponseData)
if err != nil {
loggermdl.LogError("Failed to marshall statitics - ", err)
c.SetStatusCode(417)
return nil
}
c.SetContentType("application/json")
c.WriteData(string(ba))
c.SetStatusCode(200)
return nil
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment