Moved package api to subsonic under server

This commit is contained in:
Deluan 2020-01-19 18:21:44 -05:00
parent 67eeb218c4
commit 7610b42f4b
59 changed files with 41 additions and 41 deletions

View file

@ -1,12 +1,12 @@
package api package subsonic
import ( import (
"errors" "errors"
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/cloudsonic/sonic-server/utils" "github.com/cloudsonic/sonic-server/utils"
) )

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"errors" "errors"

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"encoding/json" "encoding/json"
@ -6,15 +6,15 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/conf" "github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/go-chi/chi" "github.com/go-chi/chi"
) )
const Version = "1.8.0" const Version = "1.8.0"
type SubsonicHandler = func(http.ResponseWriter, *http.Request) (*responses.Subsonic, error) type Handler = func(http.ResponseWriter, *http.Request) (*responses.Subsonic, error)
type Router struct { type Router struct {
Browser engine.Browser Browser engine.Browser
@ -123,7 +123,7 @@ func (api *Router) routes() http.Handler {
// Add the Subsonic handler, with and without `.view` extension // Add the Subsonic handler, with and without `.view` extension
// Ex: if path = `ping` it will create the routes `/ping` and `/ping.view` // Ex: if path = `ping` it will create the routes `/ping` and `/ping.view`
func H(r chi.Router, path string, f SubsonicHandler) { func H(r chi.Router, path string, f Handler) {
handle := func(w http.ResponseWriter, r *http.Request) { handle := func(w http.ResponseWriter, r *http.Request) {
res, err := f(w, r) res, err := f(w, r)
if err != nil { if err != nil {

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"testing" "testing"

View file

@ -1,15 +1,15 @@
package api package subsonic
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"time" "time"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/conf" "github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/cloudsonic/sonic-server/utils" "github.com/cloudsonic/sonic-server/utils"
) )

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"fmt" "fmt"
@ -7,9 +7,9 @@ import (
"strings" "strings"
"time" "time"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/cloudsonic/sonic-server/utils" "github.com/cloudsonic/sonic-server/utils"
) )

View file

@ -1,13 +1,13 @@
package api package subsonic
import ( import (
"net/http" "net/http"
"time" "time"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type MediaAnnotationController struct { type MediaAnnotationController struct {

View file

@ -1,14 +1,14 @@
package api package subsonic
import ( import (
"io" "io"
"net/http" "net/http"
"os" "os"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type MediaRetrievalController struct { type MediaRetrievalController struct {

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"errors" "errors"

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"context" "context"
@ -8,9 +8,9 @@ import (
"net/http" "net/http"
"strings" "strings"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/conf" "github.com/cloudsonic/sonic-server/conf"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
func checkRequiredParameters(next http.Handler) http.Handler { func checkRequiredParameters(next http.Handler) http.Handler {

View file

@ -1,4 +1,4 @@
package api package subsonic
import ( import (
"net/http" "net/http"

View file

@ -1,13 +1,13 @@
package api package subsonic
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type PlaylistsController struct { type PlaylistsController struct {

View file

@ -10,7 +10,7 @@ import (
"encoding/xml" "encoding/xml"
"time" "time"
. "github.com/cloudsonic/sonic-server/api/responses" . "github.com/cloudsonic/sonic-server/server/subsonic/responses"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )

View file

@ -1,12 +1,12 @@
package api package subsonic
import ( import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type SearchingController struct { type SearchingController struct {

View file

@ -1,12 +1,12 @@
package api package subsonic
import ( import (
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/log" "github.com/cloudsonic/sonic-server/log"
"github.com/cloudsonic/sonic-server/model" "github.com/cloudsonic/sonic-server/model"
"github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/cloudsonic/sonic-server/utils" "github.com/cloudsonic/sonic-server/utils"
) )

View file

@ -1,9 +1,9 @@
package api package subsonic
import ( import (
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses" "github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type SystemController struct{} type SystemController struct{}

View file

@ -1,9 +1,9 @@
package api package subsonic
import ( import (
"net/http" "net/http"
"github.com/cloudsonic/sonic-server/api/responses" "github.com/cloudsonic/sonic-server/server/subsonic/responses"
) )
type UsersController struct{} type UsersController struct{}

View file

@ -3,7 +3,7 @@
//go:generate wire //go:generate wire
//+build !wireinject //+build !wireinject
package api package subsonic
import ( import (
"github.com/google/wire" "github.com/google/wire"

View file

@ -1,6 +1,6 @@
//+build wireinject //+build wireinject
package api package subsonic
import ( import (
"github.com/google/wire" "github.com/google/wire"

View file

@ -7,7 +7,7 @@ import (
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"github.com/cloudsonic/sonic-server/api/responses" "github.com/cloudsonic/sonic-server/server/subsonic/responses"
"github.com/smartystreets/goconvey/convey" "github.com/smartystreets/goconvey/convey"
) )

View file

@ -6,11 +6,11 @@
package main package main
import ( import (
"github.com/cloudsonic/sonic-server/api"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/persistence" "github.com/cloudsonic/sonic-server/persistence"
"github.com/cloudsonic/sonic-server/scanner" "github.com/cloudsonic/sonic-server/scanner"
"github.com/cloudsonic/sonic-server/server" "github.com/cloudsonic/sonic-server/server"
"github.com/cloudsonic/sonic-server/server/subsonic"
"github.com/google/wire" "github.com/google/wire"
) )
@ -23,7 +23,7 @@ func CreateApp(musicFolder string) *server.Server {
return serverServer return serverServer
} }
func CreateSubsonicAPIRouter() *api.Router { func CreateSubsonicAPIRouter() *subsonic.Router {
dataStore := persistence.New() dataStore := persistence.New()
browser := engine.NewBrowser(dataStore) browser := engine.NewBrowser(dataStore)
cover := engine.NewCover(dataStore) cover := engine.NewCover(dataStore)
@ -33,10 +33,10 @@ func CreateSubsonicAPIRouter() *api.Router {
ratings := engine.NewRatings(dataStore) ratings := engine.NewRatings(dataStore)
scrobbler := engine.NewScrobbler(dataStore, nowPlayingRepository) scrobbler := engine.NewScrobbler(dataStore, nowPlayingRepository)
search := engine.NewSearch(dataStore) search := engine.NewSearch(dataStore)
router := api.NewRouter(browser, cover, listGenerator, playlists, ratings, scrobbler, search) router := subsonic.NewRouter(browser, cover, listGenerator, playlists, ratings, scrobbler, search)
return router return router
} }
// wire_injectors.go: // wire_injectors.go:
var allProviders = wire.NewSet(engine.Set, scanner.New, api.NewRouter, persistence.Set) var allProviders = wire.NewSet(engine.Set, scanner.New, subsonic.NewRouter, persistence.Set)

View file

@ -3,18 +3,18 @@
package main package main
import ( import (
"github.com/cloudsonic/sonic-server/api"
"github.com/cloudsonic/sonic-server/engine" "github.com/cloudsonic/sonic-server/engine"
"github.com/cloudsonic/sonic-server/persistence" "github.com/cloudsonic/sonic-server/persistence"
"github.com/cloudsonic/sonic-server/scanner" "github.com/cloudsonic/sonic-server/scanner"
"github.com/cloudsonic/sonic-server/server" "github.com/cloudsonic/sonic-server/server"
"github.com/cloudsonic/sonic-server/server/subsonic"
"github.com/google/wire" "github.com/google/wire"
) )
var allProviders = wire.NewSet( var allProviders = wire.NewSet(
engine.Set, engine.Set,
scanner.New, scanner.New,
api.NewRouter, subsonic.NewRouter,
persistence.Set, persistence.Set,
) )
@ -25,6 +25,6 @@ func CreateApp(musicFolder string) *server.Server {
)) ))
} }
func CreateSubsonicAPIRouter() *api.Router { func CreateSubsonicAPIRouter() *subsonic.Router {
panic(wire.Build(allProviders)) panic(wire.Build(allProviders))
} }