renamed things so IDE would not yell at me
This commit is contained in:
4
main.go
4
main.go
@@ -106,12 +106,12 @@ func getAllChirpsHandler(cfg *apiConfig) http.HandlerFunc {
|
|||||||
func getChirpByIDHandler(cfg *apiConfig) http.HandlerFunc {
|
func getChirpByIDHandler(cfg *apiConfig) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
uuid, err := uuid.Parse(r.PathValue("chirpID"))
|
chirpID, err := uuid.Parse(r.PathValue("chirpID"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpResponse.JSONHandler(w, http.StatusBadRequest, `{"error": "InvalidChirpID"}`)
|
httpResponse.JSONHandler(w, http.StatusBadRequest, `{"error": "InvalidChirpID"}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
chirp, err := cfg.db.GetChirpByID(context.Background(), uuid)
|
chirp, err := cfg.db.GetChirpByID(context.Background(), chirpID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
httpResponse.JSONHandler(w, http.StatusNotFound, `{"error": "ChirpNotFound"}`)
|
httpResponse.JSONHandler(w, http.StatusNotFound, `{"error": "ChirpNotFound"}`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user