redis starter
This commit is contained in:
parent
191324c071
commit
1291c41e2d
@ -73,10 +73,15 @@ func newUser(w http.ResponseWriter, r *http.Request) {
|
||||
id := uuid.New()
|
||||
|
||||
username := r.URL.Query().Get("username")
|
||||
|
||||
if username == "" {
|
||||
http.Error(w, "USERNAME is required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
//user_slot, err := rdb.Incr(ctx, "user_slot")
|
||||
|
||||
/// rdb.ZADD(ctx, "user_name", username
|
||||
|
||||
// fmt.Println(id.String())
|
||||
json.NewEncoder(w).Encode(Message{ID: id.String(), Content: username})
|
||||
}
|
||||
@ -152,6 +157,9 @@ func main() {
|
||||
http.HandleFunc("/newUser", newUser)
|
||||
http.HandleFunc("/bet", takeBet)
|
||||
|
||||
sc, _ := rdb.Incr(ctx, "user_slot").Result()
|
||||
log.Println(sc)
|
||||
|
||||
log.Println("Server started at :8080")
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user