Feat: add example config
This commit is contained in:
		| @@ -56,10 +56,6 @@ func removeRoom(roomID string) { | ||||
| } | ||||
|  | ||||
| // context | ||||
| func getRoomIDFromCtx(ctx context.Context) string { | ||||
| 	id, _ := ctx.Value(models.CtxRoomIDKey).(string) | ||||
| 	return id | ||||
| } | ||||
|  | ||||
| func getStateByCtx(ctx context.Context) (*models.UserState, error) { | ||||
| 	username, ok := ctx.Value(models.CtxUsernameKey).(string) | ||||
| @@ -74,15 +70,6 @@ func getStateByCtx(ctx context.Context) (*models.UserState, error) { | ||||
| 	return us, nil | ||||
| } | ||||
|  | ||||
| func saveStateByCtx(ctx context.Context, state *models.UserState) error { | ||||
| 	username, ok := ctx.Value(models.CtxUsernameKey).(string) | ||||
| 	if !ok { | ||||
| 		log.Debug("no username in ctx") | ||||
| 		return errors.New("no username in ctx") | ||||
| 	} | ||||
| 	return saveState(username, state) | ||||
| } | ||||
|  | ||||
| func saveFullInfo(fi *models.FullInfo) error { | ||||
| 	// INFO: unfortunately working no transactions; so case are possible where first object is updated but the second is not | ||||
| 	if err := saveState(fi.State.Username, fi.State); err != nil { | ||||
|   | ||||
| @@ -1,12 +1,10 @@ | ||||
| package handlers | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"crypto/hmac" | ||||
| 	"crypto/sha256" | ||||
| 	"encoding/base64" | ||||
| 	"encoding/json" | ||||
| 	"errors" | ||||
| 	"fmt" | ||||
| 	"golias/models" | ||||
| 	"golias/utils" | ||||
| @@ -178,11 +176,12 @@ func cacheSetSession(key string, session *models.Session) error { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func updateRoomInSession(ctx context.Context, roomID string) (context.Context, error) { | ||||
| 	s, ok := ctx.Value(models.CtxSessionKey).(*models.Session) | ||||
| 	if !ok { | ||||
| 		return context.TODO(), errors.New("failed to extract session from ctx") | ||||
| 	} | ||||
| 	s.CurrentRoom = roomID | ||||
| 	return context.WithValue(ctx, "session", s), nil | ||||
| } | ||||
| // unused | ||||
| // func updateRoomInSession(ctx context.Context, roomID string) (context.Context, error) { | ||||
| // 	s, ok := ctx.Value(models.CtxSessionKey).(*models.Session) | ||||
| // 	if !ok { | ||||
| // 		return context.TODO(), errors.New("failed to extract session from ctx") | ||||
| // 	} | ||||
| // 	s.CurrentRoom = roomID | ||||
| // 	return context.WithValue(ctx, "session", s), nil | ||||
| // } | ||||
|   | ||||
| @@ -29,34 +29,6 @@ func init() { | ||||
| 	// go Notifier.Listen() | ||||
| } | ||||
|  | ||||
| var roundWords = map[string]string{ | ||||
| 	"hamster":    "blue", | ||||
| 	"child":      "red", | ||||
| 	"wheel":      "white", | ||||
| 	"condition":  "black", | ||||
| 	"test":       "white", | ||||
| 	"ball":       "blue", | ||||
| 	"violin":     "red", | ||||
| 	"rat":        "white", | ||||
| 	"perplexity": "blue", | ||||
| 	"notion":     "red", | ||||
| 	"guitar":     "blue", | ||||
| 	"ocean":      "blue", | ||||
| 	"moon":       "blue", | ||||
| 	"coffee":     "blue", | ||||
| 	"mountain":   "blue", | ||||
| 	"book":       "blue", | ||||
| 	"camera":     "blue", | ||||
| 	"apple":      "red", | ||||
| 	"fire":       "red", | ||||
| 	"rose":       "red", | ||||
| 	"sun":        "red", | ||||
| 	"cherry":     "red", | ||||
| 	"heart":      "red", | ||||
| 	"tomato":     "red", | ||||
| 	"cloud":      "white", | ||||
| } | ||||
|  | ||||
| func HandlePing(w http.ResponseWriter, r *http.Request) { | ||||
| 	w.Write([]byte("pong")) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder