fix: update Schema service to use new API endpoint

This commit is contained in:
Prad Nukala
2024-10-07 21:22:56 -04:00
parent af6e07323b
commit fbc640b7c4
11 changed files with 1481 additions and 122 deletions
-15
View File
@@ -1,22 +1,16 @@
package nebula
import (
"context"
"embed"
"io/fs"
"net/http"
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/pkg/nebula/models"
)
//go:embed assets
var embeddedFiles embed.FS
//go:embed nebula.pkl
var config []byte
func getHTTPFS() (http.FileSystem, error) {
fsys, err := fs.Sub(embeddedFiles, "assets")
if err != nil {
@@ -27,10 +21,6 @@ func getHTTPFS() (http.FileSystem, error) {
// UseAssets is a middleware that serves static files from the embedded assets
func UseAssets(e *echo.Echo) error {
err := models.LoadFromString(context.Background(), string(config))
if err != nil {
return err
}
fsys, err := getHTTPFS()
if err != nil {
return err
@@ -38,10 +28,5 @@ func UseAssets(e *echo.Echo) error {
assets := http.FileServer(fsys)
e.GET("/", echo.WrapHandler(assets))
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
e.GET("/_nebula/config", handleGetConfig)
return nil
}
func handleGetConfig(c echo.Context) error {
return c.Blob(http.StatusOK, "application/octet-stream", config)
}