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

Task/validation #43

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,11 @@ func main() {

places := r.PathPrefix("/places").Subrouter()
places.HandleFunc("", placeHandler.GetPlacesHandler).Methods(http.MethodGet)
places.HandleFunc("", placeHandler.PostPlaceHandler).Methods(http.MethodPost)
places.Handle("", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(placeHandler.PostPlaceHandler), logger)).Methods(http.MethodPost)
places.HandleFunc("/search/{placeName}", placeHandler.SearchPlacesHandler).Methods(http.MethodGet)
places.HandleFunc("/{id}", placeHandler.GetPlaceHandler).Methods(http.MethodGet)
places.HandleFunc("/{id}", placeHandler.PutPlaceHandler).Methods(http.MethodPut)
places.HandleFunc("/{id}", placeHandler.DeletePlaceHandler).Methods(http.MethodDelete)

places.Handle("/{id}", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(placeHandler.PutPlaceHandler), logger)).Methods(http.MethodPut)
places.Handle("/{id}", middleware.MiddlewareAuth(jwtHandler, http.HandlerFunc(placeHandler.DeletePlaceHandler), logger)).Methods(http.MethodDelete)
r.PathPrefix("/swagger").Handler(httpSwagger.WrapHandler)

reviews := places.PathPrefix("/{placeID}/reviews").Subrouter()
Expand Down
154 changes: 151 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const docTemplate = `{
}
},
"403": {
"description": "Invalid CSRF token",
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
Expand Down Expand Up @@ -256,6 +256,18 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"422": {
"description": "Unprocessable Entity",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -377,6 +389,18 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"422": {
"description": "Unprocessable Entity",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -415,6 +439,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
Expand Down Expand Up @@ -505,6 +535,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Failed to create review",
"schema": {
Expand Down Expand Up @@ -597,6 +633,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Review not found",
"schema": {
Expand Down Expand Up @@ -636,6 +678,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Review not found",
"schema": {
Expand Down Expand Up @@ -728,12 +776,24 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Invalid request",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"422": {
"description": "Unprocessable Entity",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Failed to create trip",
"schema": {
Expand Down Expand Up @@ -826,12 +886,24 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Trip not found",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"422": {
"description": "Unprocessable Entity",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Failed to update trip",
"schema": {
Expand Down Expand Up @@ -913,6 +985,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Trip not found",
"schema": {
Expand Down Expand Up @@ -1048,6 +1126,53 @@ const docTemplate = `{
}
}
},
"/users/{userID}/reviews": {
"get": {
"description": "Get all reviews for an user",
"produces": [
"application/json"
],
"summary": "Retrieve reviews by user ID",
"parameters": [
{
"type": "integer",
"description": "User ID",
"name": "userID",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "List of reviews",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/models.GetReviewByUserID"
}
}
},
"400": {
"description": "Invalid user ID",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "No reviews found for the user",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"500": {
"description": "Failed to retrieve reviews",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
}
}
}
},
"/users/{userID}/trips": {
"get": {
"description": "Get all trips for a specific user",
Expand Down Expand Up @@ -1080,6 +1205,12 @@ const docTemplate = `{
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"403": {
"description": "Invalid token",
"schema": {
"$ref": "#/definitions/httpresponses.ErrorResponse"
}
},
"404": {
"description": "Trips not found",
"schema": {
Expand Down Expand Up @@ -1126,7 +1257,7 @@ const docTemplate = `{
"name": {
"type": "string"
},
"private": {
"private_trip": {
"type": "boolean"
},
"start_date": {
Expand Down Expand Up @@ -1252,6 +1383,23 @@ const docTemplate = `{
}
}
},
"models.GetReviewByUserID": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"place_name": {
"type": "string"
},
"rating": {
"type": "integer"
},
"review_text": {
"type": "string"
}
}
},
"models.Review": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1296,7 +1444,7 @@ const docTemplate = `{
"name": {
"type": "string"
},
"private": {
"private_trip": {
"type": "boolean"
},
"start_date": {
Expand Down
Loading
Loading