Small showcase that HTTP Methods are just strings. This enables you to define your own one.
First, create a small demo webserver.
This example is in Go (store the code into a file named main.go
):
package main
import (
"fmt"
"net/http"
)
func hello(w http.ResponseWriter, req *http.Request) {
fmt.Fprint(w, "hello\n")
fmt.Fprintf(w, "Used method: %s\n", req.Method)
}
func main() {
http.HandleFunc("/hello", hello)
http.ListenAndServe(":8090", nil)
}
Second: Run it
$ go run main.go
Third, execute HTTP calls:
$ curl -X GET http://localhost:8090/hello
hello
Used method: GET
$ curl -X BEER http://localhost:8090/hello
hello
Used method: BEER