2019-05-21 11:31:40 +08:00
|
|
|
package webserver
|
2019-05-27 18:01:53 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2023-07-21 13:57:42 +08:00
|
|
|
"github.com/go-shiori/shiori/internal/config"
|
2019-05-27 18:01:53 +08:00
|
|
|
"github.com/go-shiori/shiori/internal/database"
|
|
|
|
cch "github.com/patrickmn/go-cache"
|
|
|
|
)
|
|
|
|
|
2019-10-07 14:38:40 +08:00
|
|
|
// Config is parameter that used for starting web server
|
|
|
|
type Config struct {
|
|
|
|
DB database.DB
|
|
|
|
DataDir string
|
|
|
|
ServerAddress string
|
|
|
|
ServerPort int
|
|
|
|
RootPath string
|
2022-02-19 15:22:50 +08:00
|
|
|
Log bool
|
2019-10-07 14:38:40 +08:00
|
|
|
}
|
|
|
|
|
2023-07-21 13:57:42 +08:00
|
|
|
func GetLegacyHandler(cfg Config, dependencies *config.Dependencies) *Handler {
|
2023-07-20 00:25:41 +08:00
|
|
|
return &Handler{
|
2019-10-07 14:38:40 +08:00
|
|
|
DB: cfg.DB,
|
|
|
|
DataDir: cfg.DataDir,
|
2019-05-27 18:01:53 +08:00
|
|
|
UserCache: cch.New(time.Hour, 10*time.Minute),
|
|
|
|
SessionCache: cch.New(time.Hour, 10*time.Minute),
|
2019-08-05 19:26:37 +08:00
|
|
|
ArchiveCache: cch.New(time.Minute, 5*time.Minute),
|
2019-10-07 14:38:40 +08:00
|
|
|
RootPath: cfg.RootPath,
|
2022-02-19 15:22:50 +08:00
|
|
|
Log: cfg.Log,
|
2023-07-21 13:57:42 +08:00
|
|
|
depenencies: dependencies,
|
2019-05-27 18:01:53 +08:00
|
|
|
}
|
2023-07-20 00:25:41 +08:00
|
|
|
}
|