hi i have a question about contracts. it is pretty...
# http4k
m
hi i have a question about contracts. it is pretty easy to nest routes with the normal router, but i'm not sure what syntax to use to nest contracts (ie: all endpoints share the same path segment). example (not working):
Copy code
"/tokens" bind contract {
            routes += TokenID.path bind contract {
                routes += "/" bindContract GET to ::getToken
                routes += "/"  bindContract GET to ::getToken
                routes += "/"  bindContract PUT to ::putToken
                routes += "/"  bindContract DELETE to ::removeToken
                routes += "/user" bindContract GET to ::getUser
            }
        }
d
it is more limited than the standard routing. you can't actually nest contracts in the same way, although you can nest an entire contact inside a routes block. each contract route needs to be qualified separately
m
as a sample, how would you model something like this? consider the route hierachy /tokens/{id}, /tokens/{id}/user
m
Has this changed or is there still no way to nest ContractRoutes?
d
No change ­čÖâ - you still need to model each route separately