Routes in ModularBr: how to define and manage your routes.
The ModularBr features a powerful route management capability that supports requests using the GET, POST, PUT, DELETE, and PATCH methods, following the REST architecture. Routes are added to modules through the construction of the Route class, where the method, path, and route handler are specified.
To illustrate the use of routes in ModularBr, let's consider the AppModule and add some routes to it, assuming you are using a request framework like Horse.
THorse.Get('/nfe/:id', procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)begin Modular.LoadRouteModule('/nfe/:id');try// Make use of the features of the NFeModule module here... Res.Send('ModularBr' + Modular.Get<TControllerServer>.GetNfe) .Status(200) .ContentType('application/json');finally Modular.DisposeRouteModule('/nfe/:id');end; end);