parent
ba2c8d5b27
commit
12459f97d6
5 changed files with 16 additions and 217 deletions
src/delivery
|
@ -1,7 +1,6 @@
|
|||
package resolver
|
||||
|
||||
import (
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/qbittorrent"
|
||||
"git.kmsign.ru/royalcat/tstor/src/vfs"
|
||||
"github.com/go-git/go-billy/v5"
|
||||
)
|
||||
|
@ -11,7 +10,7 @@ import (
|
|||
// It serves as dependency injection for your app, add any dependencies you require here.
|
||||
|
||||
type Resolver struct {
|
||||
QBitTorrentDaemon *qbittorrent.Daemon
|
||||
// QBitTorrentDaemon *qbittorrent.Daemon
|
||||
VFS vfs.Filesystem
|
||||
SourceFS billy.Filesystem
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/qbittorrent"
|
||||
"git.kmsign.ru/royalcat/tstor/pkg/rlog"
|
||||
"git.kmsign.ru/royalcat/tstor/src/config"
|
||||
"git.kmsign.ru/royalcat/tstor/src/daemon"
|
||||
|
@ -27,16 +26,16 @@ func Run(cfg config.WebUi, vfs vfs.Filesystem, daemons []daemon.Daemon) error {
|
|||
// Logger(),
|
||||
)
|
||||
|
||||
var qbitdaemon *qbittorrent.Daemon
|
||||
for _, dm := range daemons {
|
||||
if dm.Name() == qbittorrent.DaemonName {
|
||||
qbitdaemon = dm.(*qbittorrent.Daemon)
|
||||
}
|
||||
}
|
||||
// var qbitdaemon *qbittorrent.Daemon
|
||||
// for _, dm := range daemons {
|
||||
// if dm.Name() == qbittorrent.DaemonName {
|
||||
// qbitdaemon = dm.(*qbittorrent.Daemon)
|
||||
// }
|
||||
// }
|
||||
|
||||
echopprof.Register(r)
|
||||
|
||||
r.Any("/graphql", echo.WrapHandler((GraphQLHandler(qbitdaemon, vfs))))
|
||||
r.Any("/graphql", echo.WrapHandler((GraphQLHandler(nil, vfs))))
|
||||
r.GET("/metrics", echo.WrapHandler(promhttp.Handler()))
|
||||
|
||||
log.Info("starting webserver", "host", fmt.Sprintf("%s:%d", cfg.IP, cfg.Port))
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"context"
|
||||
"net/http"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/qbittorrent"
|
||||
|
||||
graph "git.kmsign.ru/royalcat/tstor/src/delivery/graphql"
|
||||
"git.kmsign.ru/royalcat/tstor/src/delivery/graphql/resolver"
|
||||
"git.kmsign.ru/royalcat/tstor/src/vfs"
|
||||
|
@ -20,12 +20,12 @@ func noopDirective(ctx context.Context, obj interface{}, next graphql.Resolver)
|
|||
return next(ctx)
|
||||
}
|
||||
|
||||
func GraphQLHandler(qbitdaemon *qbittorrent.Daemon, vfs vfs.Filesystem) http.Handler {
|
||||
func GraphQLHandler(vfs vfs.Filesystem) http.Handler {
|
||||
graphqlHandler := handler.NewDefaultServer(
|
||||
graph.NewExecutableSchema(
|
||||
graph.Config{
|
||||
Resolvers: &resolver.Resolver{
|
||||
QBitTorrentDaemon: qbitdaemon,
|
||||
// QBitTorrentDaemon: qbitdaemon,
|
||||
VFS: vfs,
|
||||
},
|
||||
Directives: graph.DirectiveRoot{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue