feat: add header
to meta
(ref #5317)
This commit is contained in:
parent
e719a1a456
commit
9ff83a7950
@ -11,4 +11,6 @@ type Meta struct {
|
|||||||
HSub bool `json:"h_sub"`
|
HSub bool `json:"h_sub"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
RSub bool `json:"r_sub"`
|
RSub bool `json:"r_sub"`
|
||||||
|
Header string `json:"header"`
|
||||||
|
HeaderSub bool `json:"header_sub"`
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@ type FsListResp struct {
|
|||||||
Content []ObjResp `json:"content"`
|
Content []ObjResp `json:"content"`
|
||||||
Total int64 `json:"total"`
|
Total int64 `json:"total"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
|
Header string `json:"header"`
|
||||||
Write bool `json:"write"`
|
Write bool `json:"write"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
}
|
}
|
||||||
@ -97,6 +98,7 @@ func FsList(c *gin.Context) {
|
|||||||
Content: toObjsResp(objs, reqPath, isEncrypt(meta, reqPath)),
|
Content: toObjsResp(objs, reqPath, isEncrypt(meta, reqPath)),
|
||||||
Total: int64(total),
|
Total: int64(total),
|
||||||
Readme: getReadme(meta, reqPath),
|
Readme: getReadme(meta, reqPath),
|
||||||
|
Header: getHeader(meta, reqPath),
|
||||||
Write: user.CanWrite() || common.CanWrite(meta, reqPath),
|
Write: user.CanWrite() || common.CanWrite(meta, reqPath),
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
})
|
})
|
||||||
@ -169,6 +171,13 @@ func getReadme(meta *model.Meta, path string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getHeader(meta *model.Meta, path string) string {
|
||||||
|
if meta != nil && (utils.PathEqual(meta.Path, path) || meta.HeaderSub) {
|
||||||
|
return meta.Header
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func isEncrypt(meta *model.Meta, path string) bool {
|
func isEncrypt(meta *model.Meta, path string) bool {
|
||||||
if common.IsStorageSignEnabled(path) {
|
if common.IsStorageSignEnabled(path) {
|
||||||
return true
|
return true
|
||||||
@ -225,6 +234,7 @@ type FsGetResp struct {
|
|||||||
ObjResp
|
ObjResp
|
||||||
RawURL string `json:"raw_url"`
|
RawURL string `json:"raw_url"`
|
||||||
Readme string `json:"readme"`
|
Readme string `json:"readme"`
|
||||||
|
Header string `json:"header"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Related []ObjResp `json:"related"`
|
Related []ObjResp `json:"related"`
|
||||||
}
|
}
|
||||||
@ -328,6 +338,7 @@ func FsGet(c *gin.Context) {
|
|||||||
},
|
},
|
||||||
RawURL: rawURL,
|
RawURL: rawURL,
|
||||||
Readme: getReadme(meta, reqPath),
|
Readme: getReadme(meta, reqPath),
|
||||||
|
Header: getHeader(meta, reqPath),
|
||||||
Provider: provider,
|
Provider: provider,
|
||||||
Related: toObjsResp(related, parentPath, isEncrypt(parentMeta, parentPath)),
|
Related: toObjsResp(related, parentPath, isEncrypt(parentMeta, parentPath)),
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user