mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-04 10:21:40 +00:00
feat: add local IPFS bootstrap script and refactor devbox config
This commit is contained in:
+19
-6
@@ -2,8 +2,8 @@ package nebula
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
@@ -11,9 +11,22 @@ import (
|
||||
//go:embed assets
|
||||
var embeddedFiles embed.FS
|
||||
|
||||
// UseAssets is a middleware that serves static files from the embedded assets
|
||||
func UseAssets(e *echo.Echo) echo.HandlerFunc {
|
||||
embFs := http.FS(os.DirFS("assets"))
|
||||
assets := http.FileServer(embFs)
|
||||
return echo.WrapHandler(assets)
|
||||
func getHTTPFS() (http.FileSystem, error) {
|
||||
fsys, err := fs.Sub(embeddedFiles, "assets")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return http.FS(fsys), nil
|
||||
}
|
||||
|
||||
// UseAssets is a middleware that serves static files from the embedded assets
|
||||
func UseAssets(e *echo.Echo) error {
|
||||
fsys, err := getHTTPFS()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
assets := http.FileServer(fsys)
|
||||
e.GET("/", echo.WrapHandler(assets))
|
||||
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user