fix server example

Signed-off-by: Nicolás Pazos <npazosmendez@gmail.com>
This commit is contained in:
Nicolás Pazos 2023-12-19 12:13:01 -03:00
parent 66f93860ce
commit d61fda90f2

View file

@ -58,7 +58,7 @@ func main() {
})
http.HandleFunc("/receiveMinimized", func(w http.ResponseWriter, r *http.Request) {
req, err := remote.DecodeMinimizedWriteRequest(r.Body)
req, err := remote.DecodeMinimizedWriteRequestStr(r.Body)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
@ -70,17 +70,12 @@ func main() {
for labelIdx < len(ts.LabelSymbols) {
// todo, check for overflow?
offset := ts.LabelSymbols[labelIdx]
nameIdx := ts.LabelSymbols[labelIdx]
labelIdx++
length := ts.LabelSymbols[labelIdx]
valueIdx := ts.LabelSymbols[labelIdx]
labelIdx++
name := req.Symbols[offset : offset+length]
// todo, check for overflow?
offset = ts.LabelSymbols[labelIdx]
labelIdx++
length = ts.LabelSymbols[labelIdx]
labelIdx++
value := req.Symbols[offset : offset+length]
name := req.Symbols[nameIdx]
value := req.Symbols[valueIdx]
m[model.LabelName(name)] = model.LabelValue(value)
}
fmt.Println(m)