Skip to content
This repository has been archived by the owner on Nov 12, 2023. It is now read-only.

remove deprecated #11

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions client/src/features/area/AreaExpand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export const AreaExpand = () => {
body: JSON.stringify({ fence: record.geofence }),
}).then((res) => res.json()),
)

console.log(data)
return (
<div>
<Typography variant="caption">
Expand Down
11 changes: 4 additions & 7 deletions server/routes/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package routes
import (
"encoding/json"
"flygon-admin/server/config"
"io/ioutil"

"github.com/gin-gonic/gin"
)
Expand All @@ -14,14 +13,12 @@ type Auth struct {
}

func Login(c *gin.Context) {
body, err := ioutil.ReadAll(c.Request.Body)
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}

defer c.Request.Body.Close()

var data Auth
err = json.Unmarshal(body, &data)
err := json.NewDecoder(c.Request.Body).Decode(&data)

if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
Expand Down
12 changes: 4 additions & 8 deletions server/routes/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"flygon-admin/server/config"
"flygon-admin/server/util"
"fmt"
"io/ioutil"
"net/http"
"strings"

Expand Down Expand Up @@ -56,20 +55,17 @@ func buildRequest(dest string, c *gin.Context) (int, string, error) {
return 500, fullUrl, err
}

body, err := ioutil.ReadAll(res.Body)
if err != nil {
return res.StatusCode, fullUrl, err
}
defer res.Body.Close()

// Types are not saved here since the request is just being proxied
// Reference Flygon & Golbat repos for the full types
var data interface{}
err = json.Unmarshal(body, &data)
var body interface{}
err = json.NewDecoder(res.Body).Decode(&body)
if err != nil {
return res.StatusCode, fullUrl, err
}

c.JSON(res.StatusCode, data)
c.JSON(res.StatusCode, body)
return res.StatusCode, fullUrl, nil
}

Expand Down