I have this simple program:
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/users", UsersHandler)
fmt.Println("Starting server...")
http.ListenAndServe(":8181", nil)
}
func UsersHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Users")
}
If I send a GET
command from the browser: http://localhost:8181
I can see the message "Users" printed, but If I connect from telnet no message is printed when I do:
telnet 127.0.0.1 8181
GET /users HTTP/1.1
Any idea why is that ?
You need to enter a second carriage return, which signifies the end of the headers block.