-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.go
32 lines (24 loc) · 842 Bytes
/
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
package main
import (
"fmt"
"net/http"
"github.com/proishan11/mux-rest/repository"
"github.com/proishan11/mux-rest/service"
"github.com/proishan11/mux-rest/controller"
"github.com/proishan11/mux-rest/router"
)
var (
postRepository repository.PostRepo = repository.NewFirestoreRepo()
postService service.PostService = service.NewPostService(postRepository)
postController controller.PostController = controller.NewPostController(postService)
httpRouter router.Router = router.NewMuxRouter()
)
func main() {
const port string = ":8080"
httpRouter.GET("/", func(response http.ResponseWriter, req *http.Request) {
fmt.Fprintf(response, "Server up and running")
})
httpRouter.GET("/posts", postController.GetPosts)
httpRouter.POST("/posts", postController.AddPost)
httpRouter.SERVE(port)
}