app.get
The get
method in the RoutesDefinitionApi
class is used to register a handler for HTTP GET requests in the application.
Method Signature
get<Handler extends CustomRouteHandlerFn>(
pattern: string,
handler: Handler
): GetRouteRef<GetReturnTypeOfHandler<Handler>>
Parameters
-
pattern:
string
The URL pattern that must match the request to activate this handler. This pattern can contain parameters that will be extracted from the URL and passed to the handler. -
handler:
Handler
The handler function that will be called when the request matches the pattern. This function takes context (ctx) and request (req) as arguments and returns a value that will be sent in response to the request.
Return Value
GetRouteRef<GetReturnTypeOfHandler<Handler>>
Returns a reference to the route GetRouteRef
that was created for this handler. This reference can be used to manage the route, such as navigating to it or performing related actions.