Simple http server example
This commit is contained in:
parent
697fe25cfe
commit
bea638aa28
19
http-hello/server.go
Normal file
19
http-hello/server.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Hello struct{}
|
||||
|
||||
func (h Hello) ServeHTTP(
|
||||
w http.ResponseWriter,
|
||||
r *http.Request) {
|
||||
fmt.Fprint(w, "Hello world")
|
||||
}
|
||||
|
||||
func main() {
|
||||
var h Hello
|
||||
http.ListenAndServe("localhost:4000", h)
|
||||
}
|
Loading…
Reference in New Issue
Block a user