diff options
Diffstat (limited to 'internal/apimodule/app')
-rw-r--r-- | internal/apimodule/app/app.go | 15 | ||||
-rw-r--r-- | internal/apimodule/app/appcreate.go | 4 | ||||
-rw-r--r-- | internal/apimodule/app/test/app_test.go (renamed from internal/apimodule/app/app_test.go) | 0 |
3 files changed, 11 insertions, 8 deletions
diff --git a/internal/apimodule/app/app.go b/internal/apimodule/app/app.go index 08292acd1..518192758 100644 --- a/internal/apimodule/app/app.go +++ b/internal/apimodule/app/app.go @@ -31,9 +31,11 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/router" ) -const appsPath = "/api/v1/apps" +// BasePath is the base path for this api module +const BasePath = "/api/v1/apps" -type appModule struct { +// Module implements the ClientAPIModule interface for requests relating to registering/removing applications +type Module struct { server oauth.Server db db.DB mastoConverter mastotypes.Converter @@ -42,7 +44,7 @@ type appModule struct { // New returns a new auth module func New(srv oauth.Server, db db.DB, mastoConverter mastotypes.Converter, log *logrus.Logger) apimodule.ClientAPIModule { - return &appModule{ + return &Module{ server: srv, db: db, mastoConverter: mastoConverter, @@ -51,12 +53,13 @@ func New(srv oauth.Server, db db.DB, mastoConverter mastotypes.Converter, log *l } // Route satisfies the RESTAPIModule interface -func (m *appModule) Route(s router.Router) error { - s.AttachHandler(http.MethodPost, appsPath, m.appsPOSTHandler) +func (m *Module) Route(s router.Router) error { + s.AttachHandler(http.MethodPost, BasePath, m.AppsPOSTHandler) return nil } -func (m *appModule) CreateTables(db db.DB) error { +// CreateTables creates the necessary tables for this module in the given database +func (m *Module) CreateTables(db db.DB) error { models := []interface{}{ &oauth.Client{}, &oauth.Token{}, diff --git a/internal/apimodule/app/appcreate.go b/internal/apimodule/app/appcreate.go index ec52a9d37..99b79d470 100644 --- a/internal/apimodule/app/appcreate.go +++ b/internal/apimodule/app/appcreate.go @@ -29,9 +29,9 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/oauth" ) -// appsPOSTHandler should be served at https://example.org/api/v1/apps +// AppsPOSTHandler should be served at https://example.org/api/v1/apps // It is equivalent to: https://docs.joinmastodon.org/methods/apps/ -func (m *appModule) appsPOSTHandler(c *gin.Context) { +func (m *Module) AppsPOSTHandler(c *gin.Context) { l := m.log.WithField("func", "AppsPOSTHandler") l.Trace("entering AppsPOSTHandler") diff --git a/internal/apimodule/app/app_test.go b/internal/apimodule/app/test/app_test.go index d45b04e74..d45b04e74 100644 --- a/internal/apimodule/app/app_test.go +++ b/internal/apimodule/app/test/app_test.go |