|
|
@@ -87,6 +87,10 @@ func Static(b *Binding, item *StaticBindItem) {
|
|
|
item.bind(b.routerGroup)
|
|
|
}
|
|
|
|
|
|
+func StaticFile(b *Binding, item *StaticFileBindItem) {
|
|
|
+ item.bind(b.routerGroup)
|
|
|
+}
|
|
|
+
|
|
|
// SimpleBindItem 路由条目
|
|
|
type SimpleBindItem[I any, O any] struct {
|
|
|
Path string // 请求路径
|
|
|
@@ -207,3 +211,17 @@ func (item *StaticBindItem) bind(routerGroup *gin.RouterGroup) {
|
|
|
routerGroup.Static(item.RelativePath, item.Root)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+type StaticFileBindItem struct {
|
|
|
+ RelativePath string
|
|
|
+ FilePath string
|
|
|
+ WithBasePath bool
|
|
|
+}
|
|
|
+
|
|
|
+func (item *StaticFileBindItem) bind(routerGroup *gin.RouterGroup) {
|
|
|
+ if item.WithBasePath {
|
|
|
+ routerGroup.StaticFile(strings.TrimPrefix(item.RelativePath, routerGroup.BasePath()), item.FilePath)
|
|
|
+ } else {
|
|
|
+ routerGroup.StaticFile(item.RelativePath, item.FilePath)
|
|
|
+ }
|
|
|
+}
|