1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00
miniflux-v2/daemon/routes.go

38 lines
976 B
Go
Raw Normal View History

// Copyright 2018 Frédéric Guillot. All rights reserved.
2017-11-19 21:10:04 -08:00
// Use of this source code is governed by the Apache 2.0
// license that can be found in the LICENSE file.
2018-08-24 21:51:50 -07:00
package daemon // import "miniflux.app/daemon"
2017-11-19 21:10:04 -08:00
import (
2018-08-24 21:51:50 -07:00
"miniflux.app/api"
"miniflux.app/config"
"miniflux.app/fever"
"miniflux.app/middleware"
"miniflux.app/reader/feed"
"miniflux.app/scheduler"
"miniflux.app/storage"
"miniflux.app/ui"
2017-11-19 21:10:04 -08:00
"github.com/gorilla/mux"
)
func routes(cfg *config.Config, store *storage.Storage, feedHandler *feed.Handler, pool *scheduler.WorkerPool) *mux.Router {
2017-11-19 21:10:04 -08:00
router := mux.NewRouter()
2018-04-27 20:38:46 -07:00
middleware := middleware.New(cfg, store, router)
2017-11-19 21:10:04 -08:00
if cfg.BasePath() != "" {
router = router.PathPrefix(cfg.BasePath()).Subrouter()
}
router.Use(middleware.ClientIP)
router.Use(middleware.HeaderConfig)
2018-04-27 20:38:46 -07:00
router.Use(middleware.Logging)
2017-11-19 21:10:04 -08:00
fever.Serve(router, cfg, store)
api.Serve(router, store, feedHandler)
ui.Serve(router, cfg, store, pool, feedHandler)
2018-04-27 20:38:46 -07:00
2017-11-19 21:10:04 -08:00
return router
}