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): add extra form content type and extract endpoints from path #2592

Merged
merged 1 commit into from
Nov 9, 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
2 changes: 1 addition & 1 deletion api/handler/rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func requestPayload(r *http.Request) ([]byte, error) {
}

return raw.Marshal()
case strings.Contains(myCt, "application/www-x-form-urlencoded"):
case strings.Contains(myCt, "application/www-x-form-urlencoded"), strings.Contains(myCt, "application/x-www-form-urlencoded"):
if err := r.ParseForm(); err != nil {
return nil, err
}
Expand Down
13 changes: 12 additions & 1 deletion api/router/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,22 @@ func (r *registryRouter) Route(req *http.Request) (*router.Route, error) {
handler = "rpc"
}

// extract endpoint from Path, case-sensitive
// just test it in this case, maybe should put the code somewhere else
ep_name := rsp.Method
comps := strings.Split(rsp.Path, "/")
switch len(comps) {
case 3:
ep_name = comps[1] + "." + comps[2]
case 4:
ep_name = comps[2] + "." + comps[3]
}

// construct api service
return &router.Route{
Service: name,
Endpoint: &router.Endpoint{
Name: rsp.Method,
Name: ep_name,
Handler: handler,
},
Versions: services,
Expand Down