[#XX] poc

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2024-10-23 10:40:50 +03:00
parent fc86ab3511
commit 31922f4d54
3 changed files with 36 additions and 0 deletions

View file

@ -593,10 +593,18 @@ func (a *app) configureRouter(handler *handler.Handler) {
r.POST("/upload/{cid}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.Upload)))))) r.POST("/upload/{cid}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.Upload))))))
a.log.Info(logs.AddedPathUploadCid) a.log.Info(logs.AddedPathUploadCid)
r.GET("/get/{cid}/{oid:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadByAddressOrBucketName)))))) r.GET("/get/{cid}/{oid:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadByAddressOrBucketName))))))
r.OPTIONS("/get/{cid}/{oid:*}", func(ctx *fasthttp.RequestCtx) {
ctx.Response.Header.Set(fasthttp.HeaderAccessControlAllowOrigin, "*")
ctx.Response.Header.Set(fasthttp.HeaderAccessControlAllowHeaders, "Authorization")
})
r.HEAD("/get/{cid}/{oid:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.HeadByAddressOrBucketName)))))) r.HEAD("/get/{cid}/{oid:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.HeadByAddressOrBucketName))))))
a.log.Info(logs.AddedPathGetCidOid) a.log.Info(logs.AddedPathGetCidOid)
r.GET("/get_by_attribute/{cid}/{attr_key}/{attr_val:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadByAttribute)))))) r.GET("/get_by_attribute/{cid}/{attr_key}/{attr_val:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadByAttribute))))))
r.HEAD("/get_by_attribute/{cid}/{attr_key}/{attr_val:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.HeadByAttribute)))))) r.HEAD("/get_by_attribute/{cid}/{attr_key}/{attr_val:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.HeadByAttribute))))))
r.OPTIONS("/get_by_attribute/{cid}/{attr_key}/{attr_val:*}", func(ctx *fasthttp.RequestCtx) {
ctx.Response.Header.Set(fasthttp.HeaderAccessControlAllowOrigin, "*")
ctx.Response.Header.Set(fasthttp.HeaderAccessControlAllowHeaders, "Authorization")
})
a.log.Info(logs.AddedPathGetByAttributeCidAttrKeyAttrVal) a.log.Info(logs.AddedPathGetByAttributeCidAttrKeyAttrVal)
r.GET("/zip/{cid}/{prefix:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadZipped)))))) r.GET("/zip/{cid}/{prefix:*}", a.tracer(a.logger(a.canonicalizer(a.tokenizer(a.reqNamespace(handler.DownloadZipped))))))
a.log.Info(logs.AddedPathZipCidPrefix) a.log.Info(logs.AddedPathZipCidPrefix)

View file

@ -120,6 +120,7 @@ func (h *Handler) receiveFile(ctx context.Context, req request, objAddress oid.A
req.setDisposition(shouldDownload, filename) req.setDisposition(shouldDownload, filename)
req.Response.Header.Set(fasthttp.HeaderAccessControlAllowOrigin, "*")
req.Response.Header.Set(fasthttp.HeaderContentLength, strconv.FormatUint(payloadSize, 10)) req.Response.Header.Set(fasthttp.HeaderContentLength, strconv.FormatUint(payloadSize, 10))
if len(contentType) == 0 { if len(contentType) == 0 {

27
web/index.html Normal file
View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HLS DEMO</title>
<script type="module" src="https://cdn.jsdelivr.net/npm/@vime/core@^5/dist/vime/vime.esm.js"></script>
<script>
// document.cookie = "Bearer=CiQSGwoZNer6BLA9gR/BkHhEjaslCQwAOIB61j6S4RoDCJBOIAESZgohAxpsb7vfAso1F0X6hrm6WpRS14WsT3/Ct1SMoqRsT89KEkEEvePlLHzzI93xPbdiCwUPZdegyGrAaSOzPrH/sMPU1wpwR1pD5+jW3XnheX1CN1d1AnnJtXSPAbCgt9h2PWp8Og==; path=/";
var origSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function () {
this.setRequestHeader('Authorization', 'Bearer CiQSGwoZNer6BLA9gR/BkHhEjaslCQwAOIB61j6S4RoDCJBOIAESZgohAxpsb7vfAso1F0X6hrm6WpRS14WsT3/Ct1SMoqRsT89KEkEEvePlLHzzI93xPbdiCwUPZdegyGrAaSOzPrH/sMPU1wpwR1pD5+jW3XnheX1CN1d1AnnJtXSPAbCgt9h2PWp8Og==')
origSend.apply(this, arguments);
};
</script>
</head>
<body>
<vm-player controls debug="true">
<vm-hls version="latest" crossOrigin="use-credentials">
<source data-src="http://localhost:8082/get/hls/index.m3u8" type="application/x-mpegURL"/>
</vm-hls>
</vm-player>
</body>
</html>