Skip to content
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

register_and_login #4

Merged
merged 2 commits into from
Sep 28, 2024
Merged

register_and_login #4

merged 2 commits into from
Sep 28, 2024

Conversation

Qaleka
Copy link
Collaborator

@Qaleka Qaleka commented Sep 27, 2024

No description provided.

main.go Show resolved Hide resolved
main.go Outdated
@@ -47,6 +199,10 @@ func main() {

router.HandleFunc("/api/ads", getAllPlaces).Methods("GET")

router.HandleFunc("/api/auth/register", registerUser).Methods("POST")
router.HandleFunc("/api/auth/login", loginUser).Methods("POST")
router.HandleFunc("/api/auth/logout", logoutUser).Methods("POST")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

повторяющийся элемент /api можно вынести в отдельную переменную или сделать несколько отдельных более длинных

main.go Outdated

_, err := rand.Read(b)
if err != nil {
log.Fatalf("Failed to generate random session ID: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Fatalf только в main ф-и используй

main.go Outdated
{ID: 3, Username: "kerla", Password: "kerla123", Email: "kerla1337@example.com"},
{ID: 4, Username: "animeLover", Password: "neruto", Email: "nikitasuper@example.com"},
}

var places = []Place{
{ID: 1, Title: "Уютный диван в центре города", Description: "Привет! Я предлагаю место на своем диване для путешественников.", Location: "Moscow", Host: Host{ID: 1, Username: "johndoe", Email: "johndoe@example.com"}, AvailableDates: []string{"2024-05-01", "2024-05-15"}, Rating: 9.1},
{ID: 1, Title: "Приглашаю иностранцев к себе", Description: "Хаюшки, приезжайте все ко мне!.", Location: "Sochi", Host: Host{ID: 2, Username: "oleg", Email: "oleg228@example.com"}, AvailableDates: []string{"2024-05-01", "2024-05-15"}, Rating: 10},
{ID: 1, Title: "Нет места, где переночевать?", Description: "Приючу у себя людей на пару дней.", Location: "Chita", Host: Host{ID: 3, Username: "kerla", Email: "kerla1337@example.com"}, AvailableDates: []string{"2024-05-01", "2024-05-15"}, Rating: 8.5},
{ID: 1, Title: "Хочу поболтать с японцами", Description: "Охае, приезжайте ко мне, анимешники", Location: "Khabarovsk", Host: Host{ID: 4, Username: "animeLover", Email: "nikitasuper@example.com"}, AvailableDates: []string{"2024-05-01", "2024-05-15"}, Rating: 8.8},
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынеси моки в отдельный файл, уж очень засоряют код

@Antihoman Antihoman merged commit 148aa1f into main Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants