This is especially useful when combined with String Interpolating Routing DSL also known as SIRD routing, or when working with sub projects that route using several routes files. You can tell the routes file to use a different router under a specific prefix by using “->” followed by the given prefix: -> /api api.MyRouter You can also add comments to the route file, with the # character. Let’s see what a route definition looks like: GET /clients/:id (id: Long)Įach route starts with the HTTP method, followed by the URI pattern. Each route consists of an HTTP method and URI pattern, both associated with a call to an Action generator. This file lists all of the routes needed by the application. §The routes file syntaxĬonf/routes is the configuration file used by the router. If you wish to use your own static state you can still do so in a controller that is a class. That is no longer supported, as Play no longer relies on static state. That means the class is suitable for use with dependency injection and can also be instantiated manually using the constructor.īefore Play 2.7.0, Play supported a static routes generator that allowed defining controllers as objects instead of classes. Play’s default routes generator creates a router class that accepts controller instances in an constructor. This means that you’ll see route errors directly in your browser: Routes are defined in the conf/routes file, which is compiled. clients/1542, /photos/list), including the query string This event contains two major pieces of information: The router is the component in charge of translating each incoming HTTP request to an Action.Īn HTTP request is seen as an event by the MVC framework. English ▾ English Български Français 日本語 Türkçe HTTP programming
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |