ggicci/httpin

Feature: when context(httpin.Input) is nil, then create a new struct

cgxxv opened this issue · 0 comments

cgxxv commented
func ListUsers(rw http.ResponseWriter, r *http.Request) {
    input := r.Context().Value(httpin.Input).(*ListUsersInput)
    fmt.Printf("input: %#v\n", input)
}

In this code, when r.Context().Value(httpin.Input) is nil, then create a new ListUsersInput with the refect pkg.

This can be done, but need some code changed. So we can avoid the nil panic error.