Skip to content

Commit

Permalink
feat(api): request.get_uri_captures (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlightIbuki authored Oct 19, 2022
1 parent 5775452 commit 287b737
Show file tree
Hide file tree
Showing 3 changed files with 876 additions and 765 deletions.
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

0 comments on commit 287b737

Please sign in to comment.