aadd first files based on caddy-filemanager

This commit is contained in:
Henrique Dias committed 2017-06-18 13:57:38 +01:00
1 parent f185b9893b
commit 20baeeb41a
28 files changed
+10626 -1

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package assets
import (
"mime"
"net/http"
"path/filepath"
"strings"
"github.com/hacdias/filemanager"
)
// BaseURL is the url of the assets
const BaseURL = "/_filemanagerinternal"
// Serve provides the needed assets for the front-end
func Serve(w http.ResponseWriter, r *http.Request, c *filemanager.Config) (int, error) {
// gets the filename to be used with Assets function
filename := strings.Replace(r.URL.Path, c.BaseURL+BaseURL, "public", 1)
file, err := Asset(filename)
if err != nil {
return http.StatusNotFound, nil
}
// Get the file extension and its mimetype
extension := filepath.Ext(filename)
mediatype := mime.TypeByExtension(extension)
// Write the header with the Content-Type and write the file
// content to the buffer
w.Header().Set("Content-Type", mediatype)
w.Write(file)
return 200, nil
}
+8144
View File
File diff suppressed because it is too large. Load diff