You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Use class method or function as request handler
223
+
Fano Framework provides `TMethodRequestHandler` and `TFuncRequestHandler` adapter class which implements `IRequestHandler` interface to allow use of method or function as request handler. For example, using `TUserController` class above,
Copy file name to clipboardexpand all lines: working-with-router/index.md
+7-6
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ description: Tutorial on how to work with router in Fano Framework
7
7
8
8
## Router and route
9
9
10
-
In Fano Framework, a route is an association rule between URL path pattern, HTTP method and code that handles it. Router manages one or more routes and match request URL path, extract data in it and select code that handles it. Router is any class implements `IRouter` interface.
10
+
In Fano Framework, a route is an association rule between URL path pattern, HTTP method and code that handles it. Router manages one or more routes and match request URL path, extract data in it and select code that handles it (request handler instance, i.e., [controller](/working-with-controllers)). Router is any class implements `IRouter` interface.
11
11
12
12
### Creating route for GET method
13
13
@@ -98,7 +98,7 @@ If client opens `http://example.com/not/exists` through browser, our application
98
98
99
99
## <aname="route-builder"></a>Build application routes with route builder
100
100
101
-
To build application routes, you need to create class that implements `IRouteBuilder` interface.
101
+
To build application routes, you need to create class that implements `IRouteBuilder` interface.
If you need only static URL path pattern, you should use it.
308
+
If you need only static URL path pattern, you should use it.
309
309
310
-
If you create application service provider inherit from `TBasicAppServiceProvider`, it will create default router using `TSimpleRouterFactory` class which is good enough for most applications.
310
+
If you create application service provider inherit from `TBasicAppServiceProvider`, it will create default router using `TSimpleRouterFactory` class which is good enough for most applications.
311
311
312
312
## Replace router instance
313
313
If you want to replace router with different implementation, you can override `buildRouter()` method of `TBasicAppServiceProvider`. For example,
@@ -326,19 +326,20 @@ begin
326
326
ctnr.add('router', TRouterFactory.create());
327
327
result := ctnr['router'] as IRouter;
328
328
fRouteMatcher := result as IRouteMatcher;
329
-
end;
329
+
end;
330
330
331
331
function TMyAppProvider.getRouteMatcher() : IRouteMatcher;
332
332
begin
333
333
result := fRouteMatcher;
334
-
end;
334
+
end;
335
335
```
336
336
Note that `IRouteMatcher` is interface which is responsible to match request URL and `TRouter` implements it.
337
337
338
338
## Explore more
339
339
340
340
-[Dispatcher](/dispatcher).
341
341
-[Middlewares](/middlewares).
342
+
-[Working with Controller](/working-with-controller).
0 commit comments