implement unmarshaling straight into MethodData
This commit is contained in:
@@ -2,7 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -149,7 +148,7 @@ type friendAddPOSTData struct {
|
||||
// FriendsAddPOST allows for adding friends. Yup. Easy as that.
|
||||
func FriendsAddPOST(md common.MethodData) (r common.Response) {
|
||||
d := friendAddPOSTData{}
|
||||
err := json.Unmarshal(md.RequestData, &d)
|
||||
err := md.RequestData.Unmarshal(&d)
|
||||
if err != nil {
|
||||
md.Err(err)
|
||||
r = Err500
|
||||
@@ -220,7 +219,7 @@ func FriendsDelGET(md common.MethodData) common.Response {
|
||||
// FriendsDelPOST allows for deleting friends.
|
||||
func FriendsDelPOST(md common.MethodData) (r common.Response) {
|
||||
d := friendAddPOSTData{}
|
||||
err := json.Unmarshal(md.RequestData, &d)
|
||||
err := md.RequestData.Unmarshal(&d)
|
||||
if err != nil {
|
||||
md.Err(err)
|
||||
r = Err500
|
||||
|
@@ -3,7 +3,6 @@ package v1
|
||||
import (
|
||||
"crypto/md5"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/osuripple/api/common"
|
||||
@@ -31,7 +30,7 @@ type tokenNewOutData struct {
|
||||
// TokenNewPOST is the handler for POST /token/new.
|
||||
func TokenNewPOST(md common.MethodData) (r common.Response) {
|
||||
data := tokenNewInData{}
|
||||
err := json.Unmarshal(md.RequestData, &data)
|
||||
err := md.RequestData.Unmarshal(&data)
|
||||
if err != nil {
|
||||
r = ErrBadJSON
|
||||
return
|
||||
|
Reference in New Issue
Block a user