diff --git a/crm/templates/http_request.tpl b/crm/templates/http_request.tpl index 92215dd16..b728f21c1 100644 --- a/crm/templates/http_request.tpl +++ b/crm/templates/http_request.tpl @@ -2,8 +2,11 @@ package {package} import ( "net/http" + "github.com/go-chi/chi" ) +var _ = chi.URLParam + {foreach $calls as $call} // {name} {call.name} request parameters type {name|lcfirst}{call.name|ucfirst}Request struct { @@ -31,7 +34,9 @@ func ({self} *{name|lcfirst}{call.name|ucfirst}Request) Fill(r *http.Request) er } {foreach $call.parameters as $method => $params} {foreach $params as $param} -{if substr($param.type, 0, 2) !== '[]'} +{if strtolower($method) === "path"} + {self}.{param.name} = chi.URLParam(r, "{param.name}") +{elseif substr($param.type, 0, 2) !== '[]'} {self}.{param.name} = {if $param.type !== "string"}{$parsers[$param.type]}({method|strtolower}["{param.name}"]){else}{method|strtolower}["{param.name}"]{/if}{newline} {/if} {/foreach} diff --git a/crm/types.request.go b/crm/types.request.go index 2bd77bf19..0cff98a47 100644 --- a/crm/types.request.go +++ b/crm/types.request.go @@ -1,9 +1,12 @@ package crm import ( + "github.com/go-chi/chi" "net/http" ) +var _ = chi.URLParam + // Types list request parameters type typesListRequest struct { } @@ -49,7 +52,7 @@ func (t *typesTypeRequest) Fill(r *http.Request) error { post[name] = string(param[0]) } - t.id = path["id"] + t.id = chi.URLParam(r, "id") return nil }