Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Request.GetUriCaptures #130

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions request/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,18 +214,30 @@ func (r Request) GetRawBody() ([]byte, error) {
}

switch x := out.Kind.(type) {
case *kong_plugin_protocol.RawBodyResult_Content:
return x.Content, nil
case *kong_plugin_protocol.RawBodyResult_Content:
return x.Content, nil

case *kong_plugin_protocol.RawBodyResult_BodyFilepath:
return ioutil.ReadFile(x.BodyFilepath)
case *kong_plugin_protocol.RawBodyResult_BodyFilepath:
return ioutil.ReadFile(x.BodyFilepath)

case *kong_plugin_protocol.RawBodyResult_Error:
return nil, errors.New(x.Error)
case *kong_plugin_protocol.RawBodyResult_Error:
return nil, errors.New(x.Error)

default:
return out.GetContent(), nil
default:
return out.GetContent(), nil
}
}

// kong.Request.GetUriCaptures() returns the catured URI fragements.
//
//
func (r Request) GetUriCaptures() ([][]byte, map[string][]byte, error) {
out := new(kong_plugin_protocol.UriCapturesResult)
err := r.Ask("kong.request.get_uri_captures", nil, out)
if err != nil {
return nil, nil, err
}
return out.Unnamed, out.Named, nil
}

// TODO get_body
Loading