mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Fmt and docs
This commit is contained in:
@@ -42,17 +42,17 @@ func (h *JSONProtocol) DumpJSON(req *http.Request) error {
|
|||||||
}
|
}
|
||||||
err = writeString(err, h.in, "{")
|
err = writeString(err, h.in, "{")
|
||||||
err = writeString(err, h.in, `"body":`)
|
err = writeString(err, h.in, `"body":`)
|
||||||
err = stdin.Encode(bb.String())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = stdin.Encode(bb.String())
|
||||||
err = writeString(err, h.in, ",")
|
err = writeString(err, h.in, ",")
|
||||||
defer bb.Reset()
|
defer bb.Reset()
|
||||||
err = writeString(err, h.in, `"headers":`)
|
err = writeString(err, h.in, `"headers":`)
|
||||||
err = stdin.Encode(req.Header)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
err = stdin.Encode(req.Header)
|
||||||
err = writeString(err, h.in, "}")
|
err = writeString(err, h.in, "}")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,19 +2,23 @@ package protocol
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"testing"
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"io/ioutil"
|
|
||||||
"io"
|
|
||||||
"encoding/json"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RequestData struct {
|
type RequestData struct {
|
||||||
A string `json:"a"`
|
A string `json:"a"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type fuckReed struct {
|
||||||
|
Body RequestData `json:"body"`
|
||||||
|
}
|
||||||
|
|
||||||
func TestJSONProtocolDumpJSONRequestWithData(t *testing.T) {
|
func TestJSONProtocolDumpJSONRequestWithData(t *testing.T) {
|
||||||
req := &http.Request{
|
req := &http.Request{
|
||||||
Method: http.MethodPost,
|
Method: http.MethodPost,
|
||||||
|
|||||||
@@ -78,22 +78,19 @@ Fn accepts request data of the following format:
|
|||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"body": {
|
|
||||||
"some": "input"
|
"some": "input"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Internally function receives data in following format:
|
Internally function receives data in following format:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"body": "{\"some\":\"data\"}\n",
|
"body": "{\"some\":\"input\"}\n",
|
||||||
"headers": {
|
"headers": {
|
||||||
"yo": ["dawg"]
|
"yo": ["dawg"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Function's output format should have following format:
|
Function's output format should have following format:
|
||||||
|
|||||||
Reference in New Issue
Block a user