Skip to content

Commit

Permalink
chore: update header -> headers change aligned to extism/extism#124
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice authored and zshipko committed Sep 21, 2023
1 parent 77400d7 commit 7f28a65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Binary file modified example/example.wasm
Binary file not shown.
Binary file modified example/http.wasm
Binary file not shown.
20 changes: 10 additions & 10 deletions extism_pdk.go
Expand Up @@ -196,10 +196,10 @@ func RemoveVar(key string) {
}

type HTTPRequest struct {
url string
header map[string]string
method string
body []byte
url string
headers map[string]string
method string
body []byte
}

type HTTPResponse struct {
Expand All @@ -222,14 +222,14 @@ func (r HTTPResponse) Status() uint16 {
}

func NewHTTPRequest(method string, url string) *HTTPRequest {
return &HTTPRequest{url: url, header: nil, method: strings.ToUpper(method), body: nil}
return &HTTPRequest{url: url, headers: nil, method: strings.ToUpper(method), body: nil}
}

func (r *HTTPRequest) SetHeader(key string, value string) *HTTPRequest {
if r.header == nil {
r.header = map[string]string{}
if r.headers == nil {
r.headers = map[string]string{}
}
r.header[key] = value
r.headers[key] = value
return r
}

Expand All @@ -242,8 +242,8 @@ func (r *HTTPRequest) Send() HTTPResponse {
arena := &fastjson.Arena{}
json := arena.NewObject()
headers := arena.NewObject()
if r.header != nil {
for k, v := range r.header {
if r.headers != nil {
for k, v := range r.headers {
headers.Set(k, arena.NewString(v))
}

Expand Down

0 comments on commit 7f28a65

Please sign in to comment.