add API boilerplate + /accounts/{accountID} and /accounts/@me endpoints
This commit is contained in:
parent
0fa769a248
commit
dfc116d828
7 changed files with 335 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package web
|
||||
|
||||
import (
|
||||
"git.sleepycat.moe/sam/mercury/internal/database"
|
||||
"git.sleepycat.moe/sam/mercury/web/api"
|
||||
"git.sleepycat.moe/sam/mercury/web/api/accounts"
|
||||
"git.sleepycat.moe/sam/mercury/web/app"
|
||||
"git.sleepycat.moe/sam/mercury/web/auth"
|
||||
"git.sleepycat.moe/sam/mercury/web/frontend"
|
||||
|
|
@ -31,4 +34,14 @@ func Routes(app *app.App) {
|
|||
r.HandleFunc("/web/@{username}", frontend.ServeUser)
|
||||
r.HandleFunc("/web/@{username}/posts/{postID}", frontend.ServeStatus)
|
||||
})
|
||||
|
||||
// APIv1 handlers
|
||||
app.Router.Route("/api/v1", func(r chi.Router) {
|
||||
// account handlers
|
||||
accounts := accounts.New(app)
|
||||
r.With(app.APIAuth(database.TokenScopeAccountsRead, true)).
|
||||
Get("/accounts/{accountID}", api.WrapHandlerT(accounts.GetID))
|
||||
r.With(app.APIAuth(database.TokenScopeAccountsMe, false)).
|
||||
Get("/accounts/@me", api.WrapHandlerT(accounts.GetMe))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue