-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.go
More file actions
27 lines (22 loc) · 902 Bytes
/
server.go
File metadata and controls
27 lines (22 loc) · 902 Bytes
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
package main
import (
"os"
"github.com/underscoreanuj/mux_api/cache"
"github.com/underscoreanuj/mux_api/controller"
"github.com/underscoreanuj/mux_api/http"
"github.com/underscoreanuj/mux_api/repository"
"github.com/underscoreanuj/mux_api/service"
)
var (
postRepository repository.PostRepository = repository.NewSQLiteRepository()
postService service.PostService = service.NewPostService(postRepository)
postCache cache.PostCache = cache.NewRedisCache("localhost:6379", 1, 10)
postController controller.PostController = controller.NewPostController(postService, postCache)
httpRouter router.Router = router.NewChiRouter()
)
func main() {
httpRouter.GET("/posts", postController.GetPosts)
httpRouter.POST("/posts", postController.AddPost)
httpRouter.GET("/posts/{id}", postController.GetPostById)
httpRouter.SERVE(os.Getenv("GO_API_PORT"))
}