44 lines
1.6 KiB
Go
44 lines
1.6 KiB
Go
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)
|
|
// Reports
|
|
router.HandleFunc("POST /note/{noteId}/report", linstromReportNote)
|
|
router.HandleFunc("DELETE /note/{noteId}/report", linstromRetractReportNote)
|
|
// Admin
|
|
router.HandleFunc("POST /note/{noteId}/admin/cw", linstromForceCWNote)
|
|
|
|
// Event streams
|
|
router.HandleFunc("/streams", linstromEventStream)
|
|
|
|
return router
|
|
}
|