30 lines
586 B
Go
30 lines
586 B
Go
package handlers
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"golias/models"
|
|
)
|
|
|
|
func createRoom(ctx context.Context, req *models.RoomReq) (*models.Room, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func getRoomByID(roomID string) (*models.Room, error) {
|
|
roomBytes, err := memcache.Get(models.CacheRoomPrefix + roomID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
resp := &models.Room{}
|
|
if err := json.Unmarshal(roomBytes, &resp); err != nil {
|
|
return nil, err
|
|
}
|
|
return resp, nil
|
|
}
|
|
|
|
// context
|
|
func getRoomIDFromCtx(ctx context.Context) string {
|
|
id, _ := ctx.Value(models.CtxRoomIDKey).(string)
|
|
return id
|
|
}
|