gofmt lol
This commit is contained in:
parent
825f2ac762
commit
0d3b4fb5ae
2 changed files with 19 additions and 20 deletions
|
@ -273,19 +273,18 @@ func apiListImages(next http.Handler, uploads string, uploadType string, udb aut
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
w.WriteHeader(422)
|
w.WriteHeader(422)
|
||||||
next.ServeHTTP(w, req)
|
next.ServeHTTP(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return http.HandlerFunc(handlerFunc)
|
return http.HandlerFunc(handlerFunc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func apiDeleteImage(next http.Handler, uploads string, uploadType string, udb auth.UserStore, dbAdapter mongodb.DbAdapter) http.Handler {
|
func apiDeleteImage(next http.Handler, uploads string, uploadType string, udb auth.UserStore, dbAdapter mongodb.DbAdapter) http.Handler {
|
||||||
handlerFunc := func(w http.ResponseWriter, req *http.Request) {
|
handlerFunc := func(w http.ResponseWriter, req *http.Request) {
|
||||||
// put the path together
|
// put the path together
|
||||||
urlParams := req.Context().Value("params").(map[string]string)
|
urlParams := req.Context().Value("params").(map[string]string)
|
||||||
tableName := urlParams["table"]
|
tableName := urlParams["table"]
|
||||||
tableKey := models.TableKey{
|
tableKey := models.TableKey{
|
||||||
Name: tableName,
|
Name: tableName,
|
||||||
|
@ -308,20 +307,20 @@ urlParams := req.Context().Value("params").(map[string]string)
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
if dbAdapter.CheckTable(tableKey) {
|
if dbAdapter.CheckTable(tableKey) {
|
||||||
// if the file exists, delete it and return 201
|
// if the file exists, delete it and return 201
|
||||||
filename := urlParams["file"]
|
filename := urlParams["file"]
|
||||||
fullPath := filepath.Join(uploads, tableName, uploadType, filename)
|
fullPath := filepath.Join(uploads, tableName, uploadType, filename)
|
||||||
s, err := os.Stat(fullPath)
|
s, err := os.Stat(fullPath)
|
||||||
if err == nil && !s.IsDir() {
|
if err == nil && !s.IsDir() {
|
||||||
err = os.Remove(fullPath)
|
err = os.Remove(fullPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
w.WriteHeader(201)
|
w.WriteHeader(201)
|
||||||
next.ServeHTTP(w, req)
|
next.ServeHTTP(w, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// otherwise, return an error
|
// otherwise, return an error
|
||||||
w.WriteHeader(500)
|
w.WriteHeader(500)
|
||||||
|
|
Loading…
Reference in a new issue