HTTP коды ответа. Когда какой использовать в Go.

Ответ

2xx: 200 OK, 201 Created (и Location), 204 No Content. 3xx: 301/302 редирект. 4xx: 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 409 Conflict, 422 Unprocessable Entity. 5xx: 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable. В Go: w.WriteHeader(code), затем w.Write(body). Для редиректа http.Redirect(w, r, url, code).

w.WriteHeader(http.StatusCreated)
w.Header().Set("Location", "/users/"+id)
json.NewEncoder(w).Encode(user)
🧠Квиз 🏆Лидеры 🎯Собесед. 📖Вопросы 📚База зн.