update depreacted ioutil call

pull/179/head
Vit Listik 3 years ago
parent 2bd9f1e733
commit ca9b9fddf1
No known key found for this signature in database
GPG Key ID: DDDF5138DA46D76B
  1. 8
      cmd/daemon/dump.go
  2. 4
      cmd/daemon/record.go

@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"github.com/curusarn/resh/internal/histcli"
"io/ioutil"
"io"
"net/http"
"github.com/curusarn/resh/internal/msg"
@ -18,17 +18,17 @@ type dumpHandler struct {
func (h *dumpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
sugar := h.sugar.With(zap.String("endpoint", "/dump"))
sugar.Debugw("Handling request, reading body ...")
jsn, err := ioutil.ReadAll(r.Body)
jsn, err := io.ReadAll(r.Body)
if err != nil {
sugar.Errorw("Error reading body", "error", err)
return
}
sugar.Debugw("Unmarshaling record ...")
sugar.Debugw("Unmarshalling record ...")
mess := msg.CliMsg{}
err = json.Unmarshal(jsn, &mess)
if err != nil {
sugar.Errorw("Error during unmarshaling",
sugar.Errorw("Error during unmarshalling",
"error", err,
"payload", jsn,
)

@ -2,7 +2,7 @@ package main
import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"github.com/curusarn/resh/internal/recordint"
@ -25,7 +25,7 @@ func (h *recordHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
sugar := h.sugar.With(zap.String("endpoint", "/record"))
sugar.Debugw("Handling request, sending response, reading body ...")
w.Write([]byte("OK\n"))
jsn, err := ioutil.ReadAll(r.Body)
jsn, err := io.ReadAll(r.Body)
// run rest of the handler as goroutine to prevent any hangups
go func() {
if err != nil {

Loading…
Cancel
Save