mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-07 13:35:22 +08:00
* migrate bookmark content route to new http server * new archive page * remove unused go generate comment * database mock * utils cleanup * unused var * domains refactor and tests * fixed secret key type * redirect to login on ui errors * fixed archive folder with storage domain * webroot documentation * some bookmark route tests * fixed error in bookmark domain for non existant bookmarks * centralice errors * add coverage data to unittests * added tests, refactor storage to use afero * removed mock to avoid increasing complexity * using deps to copy files around * remove config usage (to deps) * remove handler-ui file
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package api_v1
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/go-shiori/shiori/internal/dependencies"
|
|
"github.com/go-shiori/shiori/internal/http/middleware"
|
|
"github.com/go-shiori/shiori/internal/model"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
type APIRoutes struct {
|
|
logger *logrus.Logger
|
|
deps *dependencies.Dependencies
|
|
loginHandler model.LegacyLoginHandler
|
|
}
|
|
|
|
func (r *APIRoutes) Setup(g *gin.RouterGroup) model.Routes {
|
|
// Account API handles authentication in each route
|
|
r.handle(g, "/auth", NewAuthAPIRoutes(r.logger, r.deps, r.loginHandler))
|
|
|
|
// From here on, all routes require authentication
|
|
g.Use(middleware.AuthenticationRequired())
|
|
r.handle(g, "/bookmarks", NewBookmarksPIRoutes(r.logger, r.deps))
|
|
r.handle(g, "/tags", NewTagsPIRoutes(r.logger, r.deps))
|
|
|
|
return r
|
|
}
|
|
|
|
func (s *APIRoutes) handle(g *gin.RouterGroup, path string, routes model.Routes) {
|
|
group := g.Group(path)
|
|
routes.Setup(group)
|
|
}
|
|
|
|
func NewAPIRoutes(logger *logrus.Logger, deps *dependencies.Dependencies, loginHandler model.LegacyLoginHandler) *APIRoutes {
|
|
return &APIRoutes{
|
|
logger: logger,
|
|
deps: deps,
|
|
loginHandler: loginHandler,
|
|
}
|
|
}
|