Skip to content

Commit e11ee05

Browse files
committed
done with one task
1 parent 061210e commit e11ee05

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- optionally, forward port via your proxy or load balancer
2121

2222
#### To Do
23-
- [ ] Make std output/logs colored and pretty 😅
23+
- [x] Make std output/logs colored and pretty 😅
2424
- [ ] Add Environment Variable to switch text output to html output
25-
- [ ] Serve a html pages from a external directory
25+
- [ ] Serve a html pages from a external directory
26+
- [ ] Add volume Env var to serve volume as http dir

simple_http_server.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@ func main() {
2323

2424
func handler(w http.ResponseWriter, r *http.Request) {
2525
timestamp := time.Now()
26-
fmt.Printf("%s %s %s %s ===> from %s\n", timestamp, r.Method, r.URL, r.Proto, r.RemoteAddr)
26+
if r.Method == "GET" {
27+
fmt.Print(string("\033[34m"))
28+
} else if r.Method == "POST" {
29+
fmt.Print(string("\033[33m"))
30+
} else if r.Method == "PUT" {
31+
fmt.Print(string("\033[35m"))
32+
} else if r.Method == "DELETE" {
33+
fmt.Print(string("\033[31m"))
34+
} else {
35+
fmt.Print(string("\033[36m"))
36+
}
37+
fmt.Printf("%s %s %s %s ===> from %s\n", timestamp.Local(), r.Method, r.URL, r.Proto, r.RemoteAddr)
2738
fmt.Fprintf(w, "Request Time ==> %s\n", timestamp)
2839
fmt.Fprintf(w, "Request Type ==> %s %s %s\n", r.Method, r.URL, r.Proto)
2940
fmt.Fprintf(w, "Hostname/Host ==> %s\n", r.Host)

0 commit comments

Comments
 (0)