mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-03 07:01:35 -06:00
add get entry by name.
This commit is contained in:
+2
-1
@@ -48,11 +48,12 @@ func (manager *ApiManagerCtx) Mount(r chi.Router) {
|
||||
|
||||
r.Route("/rooms/{roomId}", func(r chi.Router) {
|
||||
r.Get("/", manager.roomGetEntry)
|
||||
r.Delete("/", manager.roomGenericAction(manager.rooms.Remove))
|
||||
r.Get("/by-name", manager.roomGetEntryByName)
|
||||
|
||||
r.Get("/settings", manager.roomGetSettings)
|
||||
r.Get("/stats", manager.roomGetStats)
|
||||
|
||||
r.Delete("/", manager.roomGenericAction(manager.rooms.Remove))
|
||||
r.Post("/start", manager.roomGenericAction(manager.rooms.Start))
|
||||
r.Post("/stop", manager.roomGenericAction(manager.rooms.Stop))
|
||||
r.Post("/restart", manager.roomGenericAction(manager.rooms.Restart))
|
||||
|
||||
@@ -133,6 +133,20 @@ func (manager *ApiManagerCtx) roomGetEntry(w http.ResponseWriter, r *http.Reques
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomGetEntryByName(w http.ResponseWriter, r *http.Request) {
|
||||
// roomId is actually room name here
|
||||
roomName := chi.URLParam(r, "roomId")
|
||||
|
||||
response, err := manager.rooms.GetEntryByName(roomName)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomGetSettings(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user