-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
51 lines (39 loc) · 1.16 KB
/
server.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
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"fmt"
"net/http"
"os"
"github.com/adesokanayo/dailywellness/controller"
router "github.com/adesokanayo/dailywellness/http"
) //
var (
postController controller.TipsManager = controller.NewPostController()
httpRouter router.Router = router.NewMuxRouter()
)
func main() {
startApp()
}
func startApp() {
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
httpRouter.GET("/health", func(resp http.ResponseWriter, req *http.Request) {
resp.Write([]byte("Health check "))
resp.WriteHeader(http.StatusOK)
resp.Write([]byte("Health check "))
fmt.Println("Landing Page loaded ")
})
httpRouter.GET("/readiness", func(resp http.ResponseWriter, req *http.Request) {
resp.Write([]byte("readiness check "))
resp.WriteHeader(http.StatusOK)
resp.Write([]byte("Readiness check "))
fmt.Println("Landing Page loaded ")
})
httpRouter.GET("/tips", postController.GetTips)
httpRouter.GET("/dailytip", postController.GetDailyTip)
httpRouter.POST("/dailytip", postController.GetTip)
httpRouter.POST("/tips", postController.AddTips)
httpRouter.GET("/randomtip", postController.GetRandomTip)
httpRouter.SERVE(":" + port)
}