Documentation
¶
Overview ¶
Package rpc exposes the app's Go services to the frontend over plain HTTP on the local transport listener — the Chromium --app window has no binding bridge of its own (docs/chromium-shell.md). One POST per call:
POST /rpc/<service>.<Method>?token=... body: JSON array of arguments
→ 200 with the method's JSON result (null when it only returns error)
→ 4xx/5xx with {"error": "..."} otherwise
Dispatch is reflection over explicitly registered services — the net/rpc pattern — so a new service method is exposed by registration alone. A method whose first parameter is a context.Context gets the request's, which is done when the caller hangs up; the JSON array carries the arguments after it. Token auth is applied by the transport mount, not here.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Preflight ¶
func Preflight(w http.ResponseWriter, r *http.Request) bool
Preflight answers the CORS handshake every POST endpoint on the listener shares, and reports whether it consumed the request. CORS is wide open on purpose: in dev the page's origin is the Vite server, not this listener, and the random token — enforced by the transport mount — is the actual auth, as with /ws. Only the OPTIONS probe is answered here; the caller still gates the method, because each endpoint spells its own refusal.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) Deny ¶
Deny hides one method ("store.Close") from dispatch — for methods that are public for Go callers but must not be reachable from the frontend.