summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/labstack/echo/v4/group_fs.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-09-05 21:00:54 +0200
committerGitHub <noreply@github.com>2022-09-05 21:00:54 +0200
commitfda05f22629156cc2eae130b501ebced2261ab42 (patch)
treeb9761fb5202ab476b11c1136a5bea69df0dd0f83 /vendor/github.com/labstack/echo/v4/group_fs.go
parent7abf1a5884bfba9ac19df26495924d86613874f3 (diff)
downloadmatterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.tar.gz
matterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.tar.bz2
matterbridge-msglm-fda05f22629156cc2eae130b501ebced2261ab42.zip
Update dependencies and fix whatsmeow API changes (#1887)
* Update dependencies * Fix whatsmau API changes
Diffstat (limited to 'vendor/github.com/labstack/echo/v4/group_fs.go')
-rw-r--r--vendor/github.com/labstack/echo/v4/group_fs.go31
1 files changed, 26 insertions, 5 deletions
diff --git a/vendor/github.com/labstack/echo/v4/group_fs.go b/vendor/github.com/labstack/echo/v4/group_fs.go
index 0a1ce4a9..aedc4c6a 100644
--- a/vendor/github.com/labstack/echo/v4/group_fs.go
+++ b/vendor/github.com/labstack/echo/v4/group_fs.go
@@ -1,9 +1,30 @@
-//go:build !go1.16
-// +build !go1.16
-
package echo
+import (
+ "io/fs"
+ "net/http"
+)
+
// Static implements `Echo#Static()` for sub-routes within the Group.
-func (g *Group) Static(prefix, root string) {
- g.static(prefix, root, g.GET)
+func (g *Group) Static(pathPrefix, fsRoot string) {
+ subFs := MustSubFS(g.echo.Filesystem, fsRoot)
+ g.StaticFS(pathPrefix, subFs)
+}
+
+// StaticFS implements `Echo#StaticFS()` for sub-routes within the Group.
+//
+// When dealing with `embed.FS` use `fs := echo.MustSubFS(fs, "rootDirectory") to create sub fs which uses necessary
+// prefix for directory path. This is necessary as `//go:embed assets/images` embeds files with paths
+// including `assets/images` as their prefix.
+func (g *Group) StaticFS(pathPrefix string, filesystem fs.FS) {
+ g.Add(
+ http.MethodGet,
+ pathPrefix+"*",
+ StaticDirectoryHandler(filesystem, false),
+ )
+}
+
+// FileFS implements `Echo#FileFS()` for sub-routes within the Group.
+func (g *Group) FileFS(path, file string, filesystem fs.FS, m ...MiddlewareFunc) *Route {
+ return g.GET(path, StaticFileHandler(file, filesystem), m...)
}