Skip to content

proposal: net/http: add API to compare HTTP request method #69513

Closed as not planned
@pixel365

Description

@pixel365

Proposal Details

Proposal Details

Quite often, inside the net/http package and in third-party packages that use net/http, you can see the following comparison of the request method:

if request.Method == "POST" {}

It's tedious to write this, so I suggest adding the following methods for the Request structure for this purpose:

func (r *Request) IsGet() bool
func (r *Request) IsHead() bool
func (r *Request) IsPost() bool
func (r *Request) IsPut() bool
func (r *Request) IsPatch() bool
func (r *Request) IsDelete() bool
func (r *Request) IsConnect() bool
func (r *Request) IsOptions() bool
func (r *Request) IsTrace() bool

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions