Routing
Routing is one of the core principles when discussing web frameworks. Somehow the clients need to know how to access the endpoints for the server. Each of these endpoints describes how to retrieve/create/manipulate data that is stored on the server. Each Component
that describes an API endpoint must have a @Controller(‘prefix’)
decorator that describes the API prefix for this component’s set of endpoints.
@
Controller
(
'hello'
)
export
class
HelloWorldController
{
@
Get
(
‘
world
’
)
printHelloWorld() {
return
‘
Hello
World
’
;
}
}
The above Controller is the API endpoint for GET /hello/world
and will return an HTTP 200 OK
with Hello World
in the body. This will be discussed more in the Routing chapter where you will learn about using URL params, Query params, and the Request object.