-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial #3
base: main
Are you sure you want to change the base?
Initial #3
Conversation
0e83c00
to
83f53ee
Compare
83f53ee
to
a5a5cb3
Compare
d5cc980
to
f5d08ad
Compare
25f5376
to
ba71236
Compare
|
||
func Login(ctx context.Context, api *api.Implementation, next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-Type", "application/json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В мидлварю
b5d74b8
to
19e8f70
Compare
cb2ac39
to
d05978c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Жду правки и тесты
func (a *App) GracefulShutdown() error { | ||
log.Println("Starting graceful shutdown") | ||
|
||
if err := a.Database.Close(); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
у тебя во время того, как выполняется шатдаун, апа все еще может принимать запросы, которые могут ходить в базу и тд. Нужно чтобы у приложения был стейт типа готово принимать, не готово или что-то подбное
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
странно, пускай будет просто internal/app/handlers/auth.go
"github.com/go-park-mail-ru/2024_2_GOATS/internal/app/models/cookie" | ||
) | ||
|
||
type AuthHandler struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Название структуры не должно начинаться с названия пакета
loginResp, errResp := a.ApiLayer.Login(a.Context, loginData) | ||
if errResp != nil { | ||
w.WriteHeader(errResp.StatusCode) | ||
json.NewEncoder(w).Encode(errResp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encode ошибку возвращает, надо обрабатывать
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Content-Type", "application/json") | ||
|
||
cookie, err := r.Cookie("session_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
коллизия с названием пакета
timeout: 4s | ||
idleTimeout: 60s | ||
|
||
# postgres: local |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
артефакт
internal/db/schema/db.sql
Outdated
|
||
INSERT INTO public.movies (title, country_id, description, release_date, movie_type) | ||
VALUES | ||
('Оно', 2, 'Когда в городке Дерри, штат Мэн, начинают пропадать дети, несколько ребят сталкиваются со своими величайшими страхами и вынуждены помериться силами со злобным клоуном Пеннивайзом, чьи проявления жестокости и список жертв уходят в глубь веков.', '2017-09-07', 'film'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не относится к схеме, это сиды
title varchar NOT NULL UNIQUE, | ||
created_at timestamp WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, | ||
updated_at timestamp WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, | ||
CONSTRAINT valid_title CHECK ( LENGTH(title) >= 3 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лично я против валидаций на уровне бд, у тебя есть приложение для этого
username varchar UNIQUE, | ||
email varchar NOT NULL UNIQUE, | ||
password_hash varchar NOT NULL, | ||
sex varchar CHECK(sex IN ('male', 'female', 'other', 'secret')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
расточительство
album_url varchar DEFAULT '', | ||
release_date date NOT NULL, | ||
rating decimal(10,2) DEFAULT '0.0', | ||
movie_type varchar CHECK(movie_type IN ('film', 'serial')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
расточительство
База для монолита на хттп