Simplified DI resolution
This commit is contained in:
+1
-2
@@ -7,7 +7,6 @@ import (
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type BrowsingController struct {
|
||||
@@ -16,7 +15,7 @@ type BrowsingController struct {
|
||||
}
|
||||
|
||||
func (c *BrowsingController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.browser)
|
||||
utils.ResolveDependencies(&c.browser)
|
||||
}
|
||||
|
||||
func (c *BrowsingController) GetMediaFolders() {
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type GetAlbumListController struct {
|
||||
@@ -20,7 +19,7 @@ type GetAlbumListController struct {
|
||||
type strategy func(offset int, size int) (*domain.Albums, error)
|
||||
|
||||
func (c *GetAlbumListController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.listGen)
|
||||
utils.ResolveDependencies(&c.listGen)
|
||||
|
||||
c.types = map[string]strategy{
|
||||
"random": func(o int, s int) (*domain.Albums, error) { return c.listGen.GetRandom(o, s) },
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type GetCoverArtController struct {
|
||||
@@ -14,7 +13,7 @@ type GetCoverArtController struct {
|
||||
}
|
||||
|
||||
func (c *GetCoverArtController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.cover)
|
||||
utils.ResolveDependencies(&c.cover)
|
||||
}
|
||||
|
||||
func (c *GetCoverArtController) Get() {
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type PlaylistsController struct {
|
||||
@@ -14,7 +13,7 @@ type PlaylistsController struct {
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.pls)
|
||||
utils.ResolveDependencies(&c.pls)
|
||||
}
|
||||
|
||||
func (c *PlaylistsController) GetAll() {
|
||||
|
||||
+1
-2
@@ -5,7 +5,6 @@ import (
|
||||
"github.com/deluan/gosonic/api/responses"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type SearchingController struct {
|
||||
@@ -14,7 +13,7 @@ type SearchingController struct {
|
||||
}
|
||||
|
||||
func (c *SearchingController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.search)
|
||||
utils.ResolveDependencies(&c.search)
|
||||
}
|
||||
|
||||
func (c *SearchingController) Search2() {
|
||||
|
||||
+1
-2
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/deluan/gosonic/domain"
|
||||
"github.com/deluan/gosonic/engine"
|
||||
"github.com/deluan/gosonic/utils"
|
||||
"github.com/karlkfi/inject"
|
||||
)
|
||||
|
||||
type StreamController struct {
|
||||
@@ -17,7 +16,7 @@ type StreamController struct {
|
||||
}
|
||||
|
||||
func (c *StreamController) Prepare() {
|
||||
inject.ExtractAssignable(utils.Graph, &c.repo)
|
||||
utils.ResolveDependencies(&c.repo)
|
||||
|
||||
c.id = c.RequiredParamString("id", "id parameter required")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user