Entity in Rubik specifies the requirements for your target route to function. Specifying your requirements explicitely comes with a lot of advantages. Let's try to specify an entity.

type MyEntity struct {
	Name string

MyEntity is a spcification of requirement of your API, which states that "my API requires name inside query to function properly."

Example Route with Entity

var myRoute = rubik.Route {
	Path: "/myPath",
	Entity: MyEntity,
	Controller: myController,

// definition of myController
func myController(req *rubik.Request) {
	entity, _ := req.Entity.(*MyEntity)
	req.Respond("You have entered name as: " + entity.Name)

// replace myRouter with Router of your choice

Lets cURL it:

curl "http://localhost:$PORT/myPath?name=tom"


You have entered name as: tom