Skip to content

net/http: suggestion employ HandlerFunc instead of func(ResponseWriter, *Request) #46926

Closed
@vituchon

Description

@vituchon

Given the function's signature at

func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Request)) {
the second parameter is of type func(ResponseWriter, *Request) that is defined as a type in the same source file, like this
type HandlerFunc func(ResponseWriter, *Request)

I guess you may (re)use the same definition instead, leading to write something like
func (mux *ServeMux) HandleFunc(pattern string, handler HandlerFunc) {

I was wondering is this is for any specific reason, if i miss something, please excuse me.

Victor.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions