D
D
ddddd tttt2019-01-26 05:46:56
go
ddddd tttt, 2019-01-26 05:46:56

Why might a 404 error occur?

r := mux.NewRouter().StrictSlash(true)
  //type = [order,user]
  r.HandleFunc("/api/photo/{type}/{type_id}/{file_id}", request.DownloadFile).Methods("GET")
  r.HandleFunc("/api/photo/{type}/{type_id}/{file_id}", request.DeleteFile).Methods("DELETE")
  r.HandleFunc("/api/photo/{type}", request.UploadFile).Methods("POST")

  err := http.ListenAndServe(":8080",r)

/api/photo/{type} works fine, but /api/photo/{type}/{type_id}/{file_id} gives 404. What could be the reason? The request goes to the addresses: localhost:8080/api/photo/user and /api/photo/user/123/adasd.png, respectively, only in the second case, for some reason, always 404.
serveFile returns 404 although the file exists.
"../../files/" + typeFile +"/"+ typeId + "/" + fileId this is how the path is formed. If you transfer it statically, then it works, but if you collect it, then 404.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey, 2019-01-26
@VladimirAndreev

/api/photo/{type}/{type_id}/{file_id}
/api/photo/123/adasd.png
And what else should be, the url does not match the mask

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question