From a541f97cd8b17e783a7660496846ed89d150f9c0 Mon Sep 17 00:00:00 2001 From: sentriz Date: Fri, 1 May 2020 02:15:12 +0100 Subject: [PATCH] lastfm: rename scrobbleopts scrobbleoptions --- cmd/gonic/main.go | 2 +- server/ctrladmin/ctrl.go | 6 ++++-- server/ctrlsubsonic/ctrl.go | 6 ++++-- server/ctrlsubsonic/ctrl_test.go | 2 +- server/ctrlsubsonic/handlers_common.go | 2 +- server/ctrlsubsonic/handlers_raw.go | 2 +- server/lastfm/lastfm.go | 4 ++-- server/server.go | 6 ++++-- 8 files changed, 18 insertions(+), 12 deletions(-) diff --git a/cmd/gonic/main.go b/cmd/gonic/main.go index c01ca23..3c20c36 100644 --- a/cmd/gonic/main.go +++ b/cmd/gonic/main.go @@ -12,8 +12,8 @@ import ( "github.com/oklog/run" "github.com/peterbourgon/ff" - "go.senan.xyz/gonic/server/db" "go.senan.xyz/gonic/server" + "go.senan.xyz/gonic/server/db" "go.senan.xyz/gonic/version" ) diff --git a/server/ctrladmin/ctrl.go b/server/ctrladmin/ctrl.go index e6ddcbf..c8bd41c 100644 --- a/server/ctrladmin/ctrl.go +++ b/server/ctrladmin/ctrl.go @@ -145,8 +145,10 @@ type Response struct { err string } -type handlerAdmin func(r *http.Request) *Response -type handlerAdminRaw func(w http.ResponseWriter, r *http.Request) +type ( + handlerAdmin func(r *http.Request) *Response + handlerAdminRaw func(w http.ResponseWriter, r *http.Request) +) //nolint:gocognit func (c *Controller) H(h handlerAdmin) http.Handler { diff --git a/server/ctrlsubsonic/ctrl.go b/server/ctrlsubsonic/ctrl.go index cf500f1..591b50c 100644 --- a/server/ctrlsubsonic/ctrl.go +++ b/server/ctrlsubsonic/ctrl.go @@ -81,8 +81,10 @@ func writeResp(w http.ResponseWriter, r *http.Request, resp *spec.Response) erro return ew.err } -type handlerSubsonic func(r *http.Request) *spec.Response -type handlerSubsonicRaw func(w http.ResponseWriter, r *http.Request) *spec.Response +type ( + handlerSubsonic func(r *http.Request) *spec.Response + handlerSubsonicRaw func(w http.ResponseWriter, r *http.Request) *spec.Response +) func (c *Controller) H(h handlerSubsonic) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/server/ctrlsubsonic/ctrl_test.go b/server/ctrlsubsonic/ctrl_test.go index ae4ca72..edb29e2 100644 --- a/server/ctrlsubsonic/ctrl_test.go +++ b/server/ctrlsubsonic/ctrl_test.go @@ -13,9 +13,9 @@ import ( jd "github.com/josephburnett/jd/lib" - "go.senan.xyz/gonic/server/db" "go.senan.xyz/gonic/server/ctrlbase" "go.senan.xyz/gonic/server/ctrlsubsonic/params" + "go.senan.xyz/gonic/server/db" ) var ( diff --git a/server/ctrlsubsonic/handlers_common.go b/server/ctrlsubsonic/handlers_common.go index 0fbb056..6e7625c 100644 --- a/server/ctrlsubsonic/handlers_common.go +++ b/server/ctrlsubsonic/handlers_common.go @@ -55,7 +55,7 @@ func (c *Controller) ServeScrobble(r *http.Request) *spec.Response { Preload("Artist"). First(track, id) // scrobble with above info - opts := lastfm.ScrobbleOpts{ + opts := lastfm.ScrobbleOptions{ Track: track, // clients will provide time in miliseconds, so use that or // instead convert UnixNano to miliseconds diff --git a/server/ctrlsubsonic/handlers_raw.go b/server/ctrlsubsonic/handlers_raw.go index b0c67c2..18fdc2d 100644 --- a/server/ctrlsubsonic/handlers_raw.go +++ b/server/ctrlsubsonic/handlers_raw.go @@ -9,9 +9,9 @@ import ( "github.com/jinzhu/gorm" - "go.senan.xyz/gonic/server/db" "go.senan.xyz/gonic/server/ctrlsubsonic/params" "go.senan.xyz/gonic/server/ctrlsubsonic/spec" + "go.senan.xyz/gonic/server/db" "go.senan.xyz/gonic/server/encode" ) diff --git a/server/lastfm/lastfm.go b/server/lastfm/lastfm.go index 0dd6367..1bad2a4 100644 --- a/server/lastfm/lastfm.go +++ b/server/lastfm/lastfm.go @@ -74,13 +74,13 @@ func GetSession(apiKey, secret, token string) (string, error) { return resp.Session.Key, nil } -type ScrobbleOpts struct { +type ScrobbleOptions struct { Track *db.Track StampMili int Submission bool } -func Scrobble(apiKey, secret, session string, opts ScrobbleOpts) error { +func Scrobble(apiKey, secret, session string, opts ScrobbleOptions) error { params := url.Values{} if opts.Submission { params.Add("method", "track.Scrobble") diff --git a/server/server.go b/server/server.go index 861dcf3..2464723 100644 --- a/server/server.go +++ b/server/server.go @@ -178,8 +178,10 @@ func setupSubsonic(r *mux.Router, ctrl *ctrlsubsonic.Controller) { r.NotFoundHandler = notFoundRoute.GetHandler() } -type funcExecute func() error -type funcInterrupt func(error) +type ( + funcExecute func() error + funcInterrupt func(error) +) func (s *Server) StartHTTP(listenAddr string) (funcExecute, funcInterrupt) { list := &http.Server{