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:The RootPkg parameter is added for the handler.tpl template. #2063

Closed
wants to merge 8 commits into from

Conversation

chenxi2015
Copy link

1、the package name is always exists
2、When I modify the handler template, I can use the rootPkg parameter, like this:

package handler

import (
    "net/http"
    "greet/response"// ①

    {% raw %}
    {{.ImportPackages}}
    {% endraw %}
)

{% raw %}
func {{.HandlerName}}(ctx *svc.ServiceContext) http.HandlerFunc {
    return func(w http.ResponseWriter, r *http.Request) {
        {{if .HasRequest}}var req types.{{.RequestType}}
        if err := httpx.Parse(r, &req); err != nil {
            httpx.Error(w, err)
            return
        }{{end}}

        l := logic.New{{.LogicType}}(r.Context(), ctx)
        {{if .HasResp}}resp, {{end}}err := l.{{.Call}}({{if .HasRequest}}req{{end}})
        {{if .HasResp}}response.Response(w, resp, err){{else}}response.Response(w, nil, err){{end}}//②
            
    }
}
{% endraw %}

the ① I can change like this:

"{{.RootPkg}}/response"

@chenxi2015 chenxi2015 changed the title feat:The parentPkg parameter is added for the template. feat:The RootPkg parameter is added for the template. Jun 29, 2022
@chenxi2015 chenxi2015 changed the title feat:The RootPkg parameter is added for the template. feat:The RootPkg parameter is added for the handler.tpl template. Jun 29, 2022
@kevwan kevwan requested a review from kesonan June 29, 2022 13:12
@chenxi2015 chenxi2015 marked this pull request as draft July 1, 2022 00:46
@kesonan
Copy link
Collaborator

kesonan commented Jul 9, 2022

Still work in progress?

@chenxi2015
Copy link
Author

Still work in progress?

Yes

@chenxi2015 chenxi2015 marked this pull request as ready for review July 18, 2022 00:20
@chenxi2015 chenxi2015 marked this pull request as draft July 20, 2022 08:09
@chenxi2015 chenxi2015 marked this pull request as ready for review July 20, 2022 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants