-
Notifications
You must be signed in to change notification settings - Fork 62
/
new.go
106 lines (101 loc) · 2.93 KB
/
new.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// SPDX-License-Identifier: AGPL-3.0-only
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>
package handler
import (
"go.uber.org/zap"
"go.uber.org/zap/buffer"
"github.com/bangumi/server/internal/app"
"github.com/bangumi/server/internal/cache"
"github.com/bangumi/server/internal/config"
"github.com/bangumi/server/internal/domain"
"github.com/bangumi/server/internal/oauth"
"github.com/bangumi/server/internal/web/captcha"
"github.com/bangumi/server/internal/web/frontend"
"github.com/bangumi/server/internal/web/handler/character"
"github.com/bangumi/server/internal/web/handler/common"
"github.com/bangumi/server/internal/web/handler/person"
"github.com/bangumi/server/internal/web/handler/subject"
"github.com/bangumi/server/internal/web/handler/user"
"github.com/bangumi/server/internal/web/rate"
"github.com/bangumi/server/internal/web/session"
)
func New(
common common.Common,
cfg config.AppConfig,
a domain.AuthService,
r domain.RevisionRepo,
topic domain.TopicRepo,
g domain.GroupRepo,
index domain.IndexRepo,
user domain.UserRepo,
cache cache.Cache,
app app.App,
captcha captcha.Manager,
session session.Manager,
rateLimit rate.Manager,
userHandler user.User,
personHandler person.Person,
log *zap.Logger,
subject subject.Subject,
engine frontend.TemplateEngine,
character character.Character,
oauth oauth.Manager,
) (Handler, error) {
return Handler{
Subject: subject,
Common: common,
app: app,
User: userHandler,
Character: character,
Person: personHandler,
cfg: cfg,
cache: cache,
log: log.Named("web.handler"),
rateLimit: rateLimit,
session: session,
a: a,
u: user,
i: index,
r: r,
topic: topic,
captcha: captcha,
g: g,
oauth: oauth,
template: engine,
buffPool: buffer.NewPool(),
}, nil
}
type Handler struct {
common.Common
Subject subject.Subject
Character character.Character
Person person.Person
app app.App
User user.User
a domain.AuthService
session session.Manager
captcha captcha.Manager
u domain.UserRepo
rateLimit rate.Manager
i domain.IndexRepo
g domain.GroupRepo
cache cache.Cache
r domain.RevisionRepo
oauth oauth.Manager
topic domain.TopicRepo
template frontend.TemplateEngine
buffPool buffer.Pool
log *zap.Logger
cfg config.AppConfig
}