Skip to content
Gx
GitHub

GX4001: no action is registered for a route type

An on: directive invokes a route type and no gx.Action or gx.Form handles that type.

Cause

An on: directive invokes a route type and no gx.Action or gx.Form handles that type.

Example

cart/Button.gx
package cart

import "app/cart/route"

<button on:click={route.Add{}}>Add</button>
cart/route/route.go
package route

import "github.com/alternayte/gx"

type Add struct {
	gx.Route `POST /cart/add`
}

gx check reports:

gx check
cart/Button.gx:5:9: GX4001: no action is registered for "Add"

Fix

  1. Declare the action, for example var Add = gx.Action(func(c *gx.Ctx, in route.Add) error { ... }).
  2. Add the action to the gx.Collect call of its slice.