gui/pkg/display/scheme_handler_example_test.go
Snider d3858dcd26 feat(gui): core:// scheme handler + 7 route dispatches
display.Service now exposes a SchemeHandler interface; new
scheme_handler.go implements the core:// dispatcher covering the
7 RFC routes:
- settings, store, network, models → core.QUERY dispatch
- agent, wallet, identity → core.ACTION dispatch

Validates URL shape (rejects paths beyond the scheme host, malformed
URLs), unknown routes return a named error. Good/Bad/Ugly tests +
godoc example.

AssetServer startup wiring deferred — no tracked Wails bootstrap
(application.New / wails.Run / AssetServer config) exists in this
worktree yet; handler is ready for wiring when that lands.

Closes tasks.lthn.sh/view.php?id=15

Co-authored-by: Codex <noreply@openai.com>
Co-Authored-By: Virgil <virgil@lethean.io>
2026-04-24 06:17:33 +01:00

25 lines
516 B
Go

package display
import (
"fmt"
"net/url"
core "dappco.re/go/core"
)
func ExampleNewCoreSchemeHandler() {
c := core.New()
c.RegisterQuery(func(_ *core.Core, q core.Query) core.Result {
name, ok := q.(string)
if !ok || name != "core.settings" {
return core.Result{}
}
return core.Result{Value: "settings-query", OK: true}
})
parsedURL, _ := url.Parse("core://settings")
result := NewCoreSchemeHandler(c).Handle(parsedURL)
fmt.Println(result.OK, result.Value)
// Output: true settings-query
}