I get my data from database and they show in browser or software like postman the same as this
/ 20221125143847
// http://localhost:3000/api/v1/datesmain/read
{
"alldates": [
{
"ID": 1,
"CreatedAt": "2022-11-25T00:00:00Z",
"UpdatedAt": "2022-11-25T00:00:00Z",
"DeletedAt": null,
"volume": "20",
"image_url": "/assets/images/IMG_3429.jpg\n",
"average_weight": 7.5,
"dates_type_id": 1,
"wight_type_id": 1
},
{
"ID": 2,
"CreatedAt": "2022-11-25T00:00:00Z",
"UpdatedAt": "2022-11-25T00:00:00Z",
"DeletedAt": null,
"volume": "15",
"image_url": "/assets/images/IMG_3436.jpg\n",
"average_weight": 7.5,
"dates_type_id": 1,
"wight_type_id": 1
}
]
}
as you se image url is currect and all images are in filder in root of project with the name of "assets" as I undrestand its possible show my image by this URL
http://localhost:3000/api/v1/datesmain/assets/images/IMG_3429.jpg
I want to show all of them as a listview in front end with java or ...
but when copy and past one of url in browser like this
// http://localhost:3000/api/v1/datesmain/static/images/IMG_3429.jpg { "message": "Not Found" }
How can I resolve that?
and this is my tiny code
func ReadAllDatesMain(e echo.Context) error {
ad, err := logic.ReadAllDatesMain()
if err != nil {
return nil
}
return e.JSON(http.StatusOK, map[string]interface{}{
"alldates": ad,
})
}
CodePudding user response:
You have defined route for your API but not for your files. You need to set static route in echo. Then you can access the folder structure by URL from client like browser or postman.