Skip to content

Commit

Permalink
docs: add adaptor README.md (#9)
Browse files Browse the repository at this point in the history
* docs: add adaptor README.md

* chore: adjust note
  • Loading branch information
ViolaPioggia committed Feb 17, 2024
1 parent 4a8bbab commit 132324b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
13 changes: 13 additions & 0 deletions adaptor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Note:

- When modifying the resp header in the server handler, please use `write` function to write the header. Otherwise, the modification will not take effect.

```go
func handler(resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("Content-Encoding", "test")
_, err := resp.Write([]byte("Content-Encoding: test\n"))
if err != nil {
panic(err)
}
}
```
11 changes: 2 additions & 9 deletions adaptor/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ package adaptor

import (
"context"
"fmt"
"io/ioutil"
"net/http"
"net/url"
Expand Down Expand Up @@ -478,16 +477,10 @@ func TestFile(t *testing.T) {
assert.NotEqual(t, req.Header.Get("Content-Type"), "application/x-www-form-urlencoded")

err := req.ParseForm()
if err != nil {
fmt.Println(err)
panic(err)
}
assert.Nil(t, err)

file, m, err := req.FormFile("file")
if err != nil {
fmt.Println(err)
panic(err)
}
assert.Nil(t, err)

assert.DeepEqual(t, m.Filename, "handler.go")

Expand Down

0 comments on commit 132324b

Please sign in to comment.