Created
February 9, 2020 10:15
-
-
Save rscarrera27/e180db8ed57feb72d8842fe2c1c11905 to your computer and use it in GitHub Desktop.
Golang HTTP handling example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Hello struct{} | |
func (h Hello) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprint(w, "Hello!") | |
} | |
func main() { | |
var h Hello | |
http.ListenAndServe("localhost:4000", h) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment