<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div dir="ltr" id="yui_3_16_0_ym19_1_1484714431063_34040"><span id="yui_3_16_0_ym19_1_1484714431063_34039">This is really a great news. Thank you, Michael and all other contributors for the great work. </span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484714431063_34040"><span><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484714431063_34040"><span id="yui_3_16_0_ym19_1_1484714431063_34063">It would only need more complete documentation with adequate demo and code samples.</span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484714431063_34040"><span><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1484714431063_34040"><span>Regards,</span></div><div></div><div id="yui_3_16_0_ym19_1_1484714431063_34068"> </div><div class="signature" id="yui_3_16_0_ym19_1_1484714431063_34070"><div id="yui_3_16_0_ym19_1_1484714431063_34069"><br></div>–Mr Bee<div id="yui_3_16_0_ym19_1_1484714431063_34099"><br></div></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue-Light, Helvetica Neue Light, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Pada Sabtu, 14 Januari 2017 5:36, Michael Van Canneyt <michael@freepascal.org> menulis:<br></font></div> <br><br> <div class="y_msg_container"><br>Hello,<br><br>I have committed a serious change to the way fpweb handles requests.<br><br>Especially routing of requests was changed.<br><br>The old Delphi style routing worked with Datamodules only. The pattern was<br>strictly /modulename/actionname or through query variables: ?module=xyz&Action=nmo<br><br>This old routing is still available by setting the LegacyRouting property of<br>webhandler or webapplication (custweb) to true. (the new routing described<br>below is then disabled)<br><br>The new routing is more flexible in 3 ways.<br><br>- It is no longer required to use datamodules, but this is still supported.<br> There are now 4 methods that can be used to register a route:<br><br> - Using a callback procedure<br> TRouteCallback = Procedure(ARequest: TRequest; AResponse);<br><br> - Using a callback event:<br> TRouteEvent = Procedure(ARequest: TRequest; AResponse) of object;<br><br> - Using an interface<br> IRouteInterface = Interface ['{10115353-10BA-4B00-FDA5-80B69AC4CAD0}']<br> Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse);<br> end;<br> Note that this is a CORBA interface, so no reference counting.<br> (although a reference counting version could be added, if desired)<br><br> - Using a router object:<br> TRouteObject = Class(TObject,IRouteInterface)<br> Public<br> Procedure HandleRequest(ARequest : TRequest; AResponse : TResponse); virtual; abstract;<br> end;<br> TRouteObjectClass = Class of TRouteObject;<br><br> The object class needs to be registered. The router will instantiate the<br> object and release it once the request was handled.<br><br> - Using a datamodule, as it used to be.<br><br> More methods can be added, if need be.<br> All routes are registered using the HTTPRouter.RegisterRoute method.<br> it is overloaded to accept any of the above parameters.<br><br>- The router can now match more complex, parametrized routes.<br><br> A route is determined by the path part of an URL; query parameters are not examined.<br><br> /path1/path2/path3/path4<br><br> In these paths, parameters and wildcards are recognized:<br><br> :param means that it will match any request with a single part in this location<br> *param means that it will match any request with zero or more path parts in this location<br><br> examples:<br><br> /path1<br> /REST/:Resource/:ID<br> /REST/:Resource<br> /*/something<br> /*path/somethiingelse<br> /*path<br><br> The parameters will be added to TRequest, they are available in the (new) RouteParams array property of TRequest.<br><br> Paths are matched case sensitively by default, and the first matching pattern is used.<br><br> The HTTP Modules are registered in the router using classname/* or defaultmodulename/*<br><br>- A set of methods can be added to the route registration (default is to accept all methods).<br> The router will match the request method. If the method does not match, it will raise an<br> exception which will result in a 405 HTTP error.<br><br>I have added a demo application. It behaves well, just as the testcases, but I would appreciate<br>feedback if you have cases where your datamodules no longer behave as they<br>used to (both with LegacyRouting=true or false)<br><br>Some more improvements to fpweb are planned, but they will not be as invasive as this.<br><br>Michael.<br>_______________________________________________<br>fpc-pascal maillist - <a ymailto="mailto:fpc-pascal@lists.freepascal.org" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a><br><a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal" target="_blank">http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br><br><br></div> </div> </div> </div></div></body></html>