Fix error handling in SwaggerJSONHandler to ensure working directory retrieval is validated
This commit is contained in:
parent
78445eaca6
commit
e63cd50954
1 changed files with 5 additions and 1 deletions
|
|
@ -34,7 +34,11 @@ func SwaggerHandler() http.HandlerFunc {
|
||||||
func SwaggerJSONHandler() http.HandlerFunc {
|
func SwaggerJSONHandler() http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
// Find the project root directory
|
// Find the project root directory
|
||||||
workDir, _ := os.Getwd()
|
workDir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
http.Error(w, "Unable to determine working directory", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Path to the swagger YAML file
|
// Path to the swagger YAML file
|
||||||
swaggerFilePath := filepath.Join(workDir, "internal", "docs", "swagger.yaml")
|
swaggerFilePath := filepath.Join(workDir, "internal", "docs", "swagger.yaml")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue