mirror of
https://github.com/harness/drone.git
synced 2025-05-05 06:21:50 +08:00

Simplify the router code by removing the translator. Now that we have Api/Git/WebHandler interfaces, they can be wrapped in handlers to do any custom request translation.
50 lines
1.4 KiB
Go
50 lines
1.4 KiB
Go
// Copyright 2021 Harness Inc. All rights reserved.
|
|
// Use of this source code is governed by the Polyform Free Trial License
|
|
// that can be found in the LICENSE.md file for this repository.
|
|
|
|
package router
|
|
|
|
import (
|
|
"github.com/google/wire"
|
|
"github.com/harness/gitness/internal/api/controller/repo"
|
|
"github.com/harness/gitness/internal/api/controller/serviceaccount"
|
|
"github.com/harness/gitness/internal/api/controller/space"
|
|
"github.com/harness/gitness/internal/api/controller/user"
|
|
"github.com/harness/gitness/internal/auth/authn"
|
|
"github.com/harness/gitness/internal/store"
|
|
)
|
|
|
|
// WireSet provides a wire set for this package.
|
|
var WireSet = wire.NewSet(
|
|
ProvideRouter,
|
|
ProvideGitHandler,
|
|
ProvideAPIHandler,
|
|
ProvideWebHandler,
|
|
)
|
|
|
|
func ProvideRouter(
|
|
api APIHandler,
|
|
git GitHandler,
|
|
web WebHandler,
|
|
) *Router {
|
|
return NewRouter(api, git, web)
|
|
}
|
|
|
|
func ProvideGitHandler(repoStore store.RepoStore, authenticator authn.Authenticator) GitHandler {
|
|
return NewGitHandler(repoStore, authenticator)
|
|
}
|
|
|
|
func ProvideAPIHandler(
|
|
systemStore store.SystemStore,
|
|
authenticator authn.Authenticator,
|
|
repoCtrl *repo.Controller,
|
|
spaceCtrl *space.Controller,
|
|
saCtrl *serviceaccount.Controller,
|
|
userCtrl *user.Controller) APIHandler {
|
|
return NewAPIHandler(systemStore, authenticator, repoCtrl, spaceCtrl, saCtrl, userCtrl)
|
|
}
|
|
|
|
func ProvideWebHandler(systemStore store.SystemStore) WebHandler {
|
|
return NewWebHandler(systemStore)
|
|
}
|