-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
34 lines (26 loc) · 897 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
33
34
package main
import (
"fmt"
"net/http"
"github.com/yudiwiradinata/go-rest-api-mux/controller"
router "github.com/yudiwiradinata/go-rest-api-mux/http"
"github.com/yudiwiradinata/go-rest-api-mux/repository"
"github.com/yudiwiradinata/go-rest-api-mux/service"
)
var (
postRepository repository.PostRepository = repository.NewFirestoreRepository()
postService service.PostService = service.NewPostService(postRepository)
postController controller.PostController = controller.NewPostController(postService)
httpRouter router.Router = router.NewChiRouter() //router.NewMuxRouter()
)
const (
PORT = ":9000"
)
func main() {
httpRouter.GET("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Println("Up and running.....")
})
httpRouter.GET("/posts", postController.GetPosts)
httpRouter.POST("/posts", postController.AddPost)
httpRouter.SERVE(PORT)
}