• With issues:
  • Use the search tool before opening a new issue.
  • Please provide source code and commit sha if you found a bug.
  • Review existing issues and provide feedback or react to them.

Description

How to reproduce

package main

import (
    "net/http"

    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()
    r.Handle("GOT", "/test", func(c *gin.Context) {
        c.JSON(http.StatusOK, gin.H{
            "message": "pong",
        })
    })
    _ = r.Run(":9999") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

Expectations


Actual result

GOT method not exists

Environment

  • go version:
  • gin version (or commit ref):
  • operating system:

Comment From: kkoehler

Hi,

gin works as expected. You register your handle to react on HTTP-Method "GOT", which is not defined in the HTTP-Spec (see https://www.rfc-editor.org/rfc/rfc9110.html#name-methods).

r.Handle("GOT"...

Change this to "GET" or better "http.MethodGet" (and corresponding import), your bug is fixed.

BTW, if you have curl installed you could also try to call the "GOT"-HTTP-Method with:

curl -X GOT http://localhost:9999/test

Kristian

Comment From: cgopher

Hi,

gin works as expected. You register your handle to react on HTTP-Method "GOT", which is not defined in the HTTP-Spec (see https://www.rfc-editor.org/rfc/rfc9110.html#name-methods).

r.Handle("GOT"...

Change this to "GET" or better "http.MethodGet" (and corresponding import), your bug is fixed.

BTW, if you have curl installed you could also try to call the "GOT"-HTTP-Method with:

curl -X GOT http://localhost:9999/test

Kristian

I think methods that do not belong to http should be filtered out