Started work on linstrom specific endpoints

Router plus a bunch of placeholder handlers
Also a poll on fedi regarding streamed events (one vs many channels)
This commit is contained in:
Melody Becker 2024-10-29 16:09:21 +01:00
parent 1fb924f59c
commit 4f4d05a335
11 changed files with 103 additions and 39 deletions

View file

@ -1 +0,0 @@
package server

View file

@ -1,5 +0,0 @@
package server
import "net/http"
func getLinstromNote(w http.ResponseWriter, r *http.Request) {}

View file

@ -1,8 +0,0 @@
package server
import "net/http"
func setupApiFrontendRouter() http.Handler {
router := http.NewServeMux()
return router
}

36
server/apiLinstrom.go Normal file
View file

@ -0,0 +1,36 @@
package server
import "net/http"
func setupLinstromApiRouter() http.Handler {
router := http.NewServeMux()
router.Handle("/v1/", http.StripPrefix("/v1", setupLinstromApiV1Router()))
return router
}
func setupLinstromApiV1Router() http.Handler {
router := http.NewServeMux()
// Notes
router.HandleFunc("GET /note/{noteId}", linstromGetNote)
router.HandleFunc("POST /note", linstromNewNote)
router.HandleFunc("PUT /note/{noteId}", linstromUpdateNote)
router.HandleFunc("DELETE /note/{noteId}", linstromDeleteNote)
// Reactions
router.HandleFunc("GET /note/{noteId}/reactions", linstromGetReactions)
router.HandleFunc("POST /note/{noteId}/reactions", linstromAddReaction)
router.HandleFunc("PUT /note/{noteId}/reactions", linstromUpdateReaction)
router.HandleFunc("DELETE /note/{noteId}/reactions", linstromDeleteReaction)
// Boosts
router.HandleFunc("GET /note/{noteId}/boosts", linstromGetBoosts)
router.HandleFunc("POST /note/{noteId}/boosts", linstromAddBoost)
router.HandleFunc("DELETE /note/{noteId}/boosts", linstromRemoveBoost)
// Quotes
router.HandleFunc("GET /note/{noteId}/quotes", linstromGetQuotes)
router.HandleFunc("POST /note/{noteId}/quotes", linstromAddQuote)
// Pinning
router.HandleFunc("POST /note/{noteId}/pin", linstromPinNote)
router.HandleFunc("DELETE /note/{noteId}/pin", linstromUnpinNote)
return router
}

View file

@ -0,0 +1,29 @@
package server
import "net/http"
// Notes
func linstromGetNote(w http.ResponseWriter, r *http.Request) {}
func linstromUpdateNote(w http.ResponseWriter, r *http.Request) {}
func linstromNewNote(w http.ResponseWriter, r *http.Request) {}
func linstromDeleteNote(w http.ResponseWriter, r *http.Request) {}
// Reactions
func linstromGetReactions(w http.ResponseWriter, r *http.Request) {}
func linstromAddReaction(w http.ResponseWriter, r *http.Request) {}
func linstromDeleteReaction(w http.ResponseWriter, r *http.Request) {}
func linstromUpdateReaction(w http.ResponseWriter, r *http.Request) {}
// Boosts
func linstromGetBoosts(w http.ResponseWriter, r *http.Request) {}
func linstromAddBoost(w http.ResponseWriter, r *http.Request) {}
func linstromRemoveBoost(w http.ResponseWriter, r *http.Request) {}
// Quotes
func linstromGetQuotes(w http.ResponseWriter, r *http.Request) {}
func linstromAddQuote(w http.ResponseWriter, r *http.Request) {}
// No delete quote since quotes are their own notes with an extra attribute
func linstromPinNote(w http.ResponseWriter, r *http.Request) {}
func linstromUnpinNote(w http.ResponseWriter, r *http.Request) {}

View file

@ -0,0 +1,5 @@
package server
// TODO: Decide where to put data stream handlers
// Entrypoint for a new stream will be in here at least

View file

@ -5,6 +5,7 @@ import "net/http"
// Mounted at /api
func setupApiRouter() http.Handler {
router := http.NewServeMux()
router.Handle("/linstrom/", setupLinstromApiRouter())
// Section MastoApi
router.HandleFunc("GET /oauth/authorize", placeholderEndpoint)