Skip to content

Commit ad31db1

Browse files
committed
organize code and write readme
1 parent 25b6c0c commit ad31db1

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"io"
6+
"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+
}
File renamed without changes.

main.go

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)