Skip to content

Commit

Permalink
Stop calling deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
bfdes committed Feb 15, 2024
1 parent a761438 commit d159bb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strings"
)
Expand Down Expand Up @@ -41,7 +41,7 @@ func CreateLinkHandler(service LinkService) http.Handler {
return
}
payload := Link{}
body, err := ioutil.ReadAll(r.Body) // DOS attack vector
body, err := io.ReadAll(r.Body) // DOS attack vector
defer r.Body.Close()
if err == nil {
err = json.Unmarshal(body, &payload)
Expand Down
4 changes: 2 additions & 2 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"errors"
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -114,7 +114,7 @@ func TestCreate(t *testing.T) {
t.Fatalf(msg, http.StatusCreated, res.StatusCode)
}
link := Link{}
body, _ := ioutil.ReadAll(res.Body)
body, _ := io.ReadAll(res.Body)
json.Unmarshal(body, &link)
if *link.Slug != slug {
t.Fail()
Expand Down

0 comments on commit d159bb5

Please sign in to comment.