Added /api/types route
This commit is contained in:
21
pages/database/types.go
Normal file
21
pages/database/types.go
Normal file
@ -0,0 +1,21 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Types shows which types are available in the database.
|
||||
func Types(ctx aero.Context) error {
|
||||
typeMap := arn.DB.Types()
|
||||
types := make([]string, 0, len(typeMap))
|
||||
|
||||
for typeName := range typeMap {
|
||||
types = append(types, typeName)
|
||||
}
|
||||
|
||||
sort.Strings(types)
|
||||
return ctx.JSON(types)
|
||||
}
|
@ -9,6 +9,7 @@ import (
|
||||
"github.com/animenotifier/notify.moe/pages/apiview"
|
||||
"github.com/animenotifier/notify.moe/pages/apiview/apidocs"
|
||||
"github.com/animenotifier/notify.moe/pages/character"
|
||||
"github.com/animenotifier/notify.moe/pages/database"
|
||||
"github.com/animenotifier/notify.moe/pages/editor/jobs"
|
||||
"github.com/animenotifier/notify.moe/pages/me"
|
||||
"github.com/animenotifier/notify.moe/pages/notifications"
|
||||
@ -50,6 +51,9 @@ func Register(app *aero.Application) {
|
||||
// Post
|
||||
app.Get("/api/post/:id/reply/ui", post.ReplyUI)
|
||||
|
||||
// Post
|
||||
app.Get("/api/types", database.Types)
|
||||
|
||||
// SoundTrack
|
||||
app.Post("/api/soundtrack/:id/download", soundtrack.Download)
|
||||
|
||||
|
Reference in New Issue
Block a user