Implement PostgreSQL storage, sessions and persistence checks

This commit is contained in:
Daria0w0
2026-10-09 18:06:28 +03:00
parent 65003b6119
commit 83e3810d33
62 changed files with 4650 additions and 20 deletions
+29
View File
@@ -0,0 +1,29 @@
package httpapi
import "net/http"
type createUserRequest struct {
Username string `json:"username"`
DisplayName string `json:"display_name"`
}
func (api *API) createUser(w http.ResponseWriter, r *http.Request) {
var body createUserRequest
if !readJSON(w, r, &body, "username", "display_name") {
return
}
user, err := api.messenger.RegisterUser(body.Username, body.DisplayName)
if err != nil {
writeAppError(w, err)
return
}
writeJSON(w, http.StatusCreated, user)
}
func (api *API) currentUser(w http.ResponseWriter, r *http.Request) {
user := userFromContext(r.Context())
writeJSON(w, http.StatusOK, user)
}