forked from kahootali/golang-sample-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (29 loc) · 977 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "No Endpoint ")
})
http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)
})
http.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Status: UP")
})
http.HandleFunc("/batch-06", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "DevOps batch 06 has started and members are awesome")
})
http.HandleFunc("/batch-06-members", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Trainer 1: Ali Kahoot\nTrainer 2: Usama Ahmed\nStudent: Mohsin Javed Cheema")
})
i := 0
http.HandleFunc("/count", func(w http.ResponseWriter, r *http.Request) {
i = i + 1
fmt.Fprintf(w, "%d", i)
})
fmt.Println("Server is Listening at 127.0.0.1:8080")
http.ListenAndServe(":8080", nil)
}