mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 13:07:09 +00:00
refactor: move Wasm related code to pkg/common/wasm
This commit is contained in:
parent
d667c3c604
commit
23f077ce75
@ -9,13 +9,14 @@ import (
|
|||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/onsonr/sonr/internal/vault"
|
"github.com/onsonr/sonr/internal/vault"
|
||||||
"github.com/onsonr/sonr/internal/vault/types"
|
"github.com/onsonr/sonr/pkg/common/wasm"
|
||||||
|
"github.com/onsonr/sonr/pkg/config/motr"
|
||||||
"github.com/onsonr/sonr/pkg/didauth/controller"
|
"github.com/onsonr/sonr/pkg/didauth/controller"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
env *types.Environment
|
env *motr.Environment
|
||||||
config *types.Config
|
config *motr.Config
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -47,8 +48,8 @@ func main() {
|
|||||||
js.Global().Set("processConfig", js.FuncOf(processConfig))
|
js.Global().Set("processConfig", js.FuncOf(processConfig))
|
||||||
|
|
||||||
e := echo.New()
|
e := echo.New()
|
||||||
e.Use(vault.WasmContextMiddleware)
|
e.Use(wasm.ContextMiddleware)
|
||||||
e.Use(controller.Middleware(nil))
|
e.Use(controller.Middleware(nil))
|
||||||
vault.RegisterRoutes(e, config)
|
vault.RegisterRoutes(e, config)
|
||||||
vault.ServeFetch(e)
|
wasm.ServeFetch(e)
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
|
||||||
"github.com/onsonr/sonr/internal/vault/context"
|
"github.com/onsonr/sonr/internal/vault/context"
|
||||||
"github.com/onsonr/sonr/internal/vault/types"
|
"github.com/onsonr/sonr/pkg/config/motr"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisterRoutes registers the Decentralized Web Node API routes.
|
// RegisterRoutes registers the Decentralized Web Node API routes.
|
||||||
func RegisterRoutes(e *echo.Echo, config *types.Config) {
|
func RegisterRoutes(e *echo.Echo, config *motr.Config) {
|
||||||
e.Use(context.Middleware(config))
|
e.Use(context.Middleware(config))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//go:build js && wasm
|
//go:build js && wasm
|
||||||
// +build js,wasm
|
// +build js,wasm
|
||||||
|
|
||||||
package vault
|
package wasm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,7 +1,7 @@
|
|||||||
//go:build js && wasm
|
//go:build js && wasm
|
||||||
// +build js,wasm
|
// +build js,wasm
|
||||||
|
|
||||||
package vault
|
package wasm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WasmContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
func ContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
// Extract WASM context from headers
|
// Extract WASM context from headers
|
||||||
if wasmCtx := c.Request().Header.Get("X-Wasm-Context"); wasmCtx != "" {
|
if wasmCtx := c.Request().Header.Get("X-Wasm-Context"); wasmCtx != "" {
|
Loading…
x
Reference in New Issue
Block a user