Creates a new chat room via HTTP handler, validates request, persists room metadata, returns confirmation.
package api
import (
"context"
"fmt"
"net/http"
"time"
"github.com/VoiceBlender/voiceblender/internal/codec"
"github.com/VoiceBlender/voiceblender/internal/leg"
"github.com/VoiceBlender/voiceblender/internal/mixer"
"github.com/go-chi/chi/v5"
)
func (s *Server) doCreateRoom(req CreateRoomRequest) (RoomView, error) {
rate := req.SampleRate
if rate == 0 {
rate = s.Config.DefaultSampleRate
}
if !mixer.ValidSampleRate(rate) {
return RoomView{}, newAPIError(http.StatusBadRequest, "invalid sample_rate: must be 8000, 16000, or 48000")
}
room, err := s.RoomMgr.Create(req.ID, req.AppID, rate)
if err != nil {
return RoomView{}, newAPIError(http.StatusConflict, "%s", err.Error())
}
if req.WebhookURL != "" {
s.Webhooks.SetRoomWebhook(room.ID, req.WebhookURL, req.WebhookSecre
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key