mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
feature (plugin): download plugin feature
This commit is contained in:
parent
028bad4141
commit
7d1853ce39
2 changed files with 14 additions and 0 deletions
|
|
@ -77,3 +77,16 @@ func PluginStaticHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||||
SendErrorResult(res, err)
|
SendErrorResult(res, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func PluginDownloadHandler(ctx *App, res http.ResponseWriter, req *http.Request) {
|
||||||
|
f, err := os.Open(JoinPath(
|
||||||
|
GetAbsolutePath(PLUGIN_PATH),
|
||||||
|
mux.Vars(req)["name"]+".zip",
|
||||||
|
))
|
||||||
|
if err != nil {
|
||||||
|
SendErrorResult(res, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
io.Copy(res, f)
|
||||||
|
f.Close()
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ func Build(r *mux.Router, a App) {
|
||||||
r.HandleFunc(WithBase("/sw.js"), http.HandlerFunc(NewMiddlewareChain(ServeFile("/assets/"), middlewares, a))).Methods("GET")
|
r.HandleFunc(WithBase("/sw.js"), http.HandlerFunc(NewMiddlewareChain(ServeFile("/assets/"), middlewares, a))).Methods("GET")
|
||||||
r.HandleFunc(WithBase("/favicon.ico"), NewMiddlewareChain(ServeFavicon, middlewares, a)).Methods("GET")
|
r.HandleFunc(WithBase("/favicon.ico"), NewMiddlewareChain(ServeFavicon, middlewares, a)).Methods("GET")
|
||||||
r.HandleFunc(WithBase("/plugin/{name}/{path:.+}"), NewMiddlewareChain(PluginStaticHandler, middlewares, a)).Methods("GET")
|
r.HandleFunc(WithBase("/plugin/{name}/{path:.+}"), NewMiddlewareChain(PluginStaticHandler, middlewares, a)).Methods("GET")
|
||||||
|
r.HandleFunc(WithBase("/plugin/{name}.zip"), NewMiddlewareChain(PluginDownloadHandler, middlewares, a)).Methods("GET")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other endpoints
|
// Other endpoints
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue