add store service

This commit is contained in:
kandrusyak
2023-06-30 17:13:46 +03:00
parent 7f4122360f
commit 8f904217f2
5 changed files with 39 additions and 7 deletions

23
services/store/store.go Normal file
View File

@@ -0,0 +1,23 @@
package store
import (
"astra-api-gateway/config"
"astra-api-gateway/pkg/api"
"github.com/labstack/echo/v4"
"net/http"
"strings"
)
func GetFileFromStore(c echo.Context) error {
fileName := strings.ReplaceAll(c.Request().RequestURI, "/store", "")
data, err, req := api.GetRequest(
config.Env.MSHosts.StoreHost+fileName,
c.Request().Header,
)
if err != nil {
return c.NoContent(http.StatusBadGateway)
}
return c.Blob(req.StatusCode, req.Header.Get("Content-Type"), data)
}