We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 25b6c0c commit ad31db1Copy full SHA for ad31db1
README.md
@@ -0,0 +1,6 @@
1
+# golang-http-server
2
+
3
+Examples on how to use Golang's standard library to run an http server.
4
5
+- [hello_world.go](hello_world.go) - a simple hello world.
6
+- [json_response.go](json_response.go) - an example with a json response.
hello_world.go
@@ -0,0 +1,17 @@
+package main
+import (
+ "fmt"
+ "io"
+ "net/http"
7
+)
8
9
+func hello(w http.ResponseWriter, r *http.Request) {
10
+ io.WriteString(w, "Hello world")
11
+}
12
13
+func main() {
14
+ http.HandleFunc("/", hello)
15
+ fmt.Println("Serving http...")
16
+ http.ListenAndServe(":8000", nil)
17
json.go renamed to json_response.go
main.go
0 commit comments