mirror of
https://github.com/aclindsa/moneygo.git
synced 2025-07-03 12:48:38 -04:00
Stop using form elements for API
Just send the JSON as the request body
This commit is contained in:
@ -1,10 +1,22 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func ReadJSON(r *http.Request, v interface{}) error {
|
||||
jsonstring, err := ioutil.ReadAll(io.LimitReader(r.Body, 10*1024*1024 /*10Mb*/))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return json.Unmarshal(jsonstring, v)
|
||||
}
|
||||
|
||||
type ResponseWrapper struct {
|
||||
Code int
|
||||
Writer ResponseWriterWriter
|
||||
|
Reference in New Issue
Block a user