You are not logged in.
Pages: 1
Hi all,
Maybe I'm missing something simple here, but this is what I am trying to do ...
I have a rather complex MVC application and I want to have a different controller (TMVCApplication) for each different area of the application i.e. I don't want ALL the code in a single unit/TMVCApplication object, as it is getting a little cumbersome.
Is there an easy way to have a single server application but have multiple controllers and/or source files split along logical lines?
Thanks in advance.
Joker.
Offline
There is no problem to have several TMVCApplication per TSQLRestServer instance:
aApplication1 := TBlogApplication1.Create;
aApplication2 := TBlogApplication2.Create;
try
aApplication1.Start(aServer);
aApplication2.Start(aServer);
aHTTPServer := TSQLHttpServer.Create('8092',aServer
{$ifndef ONLYUSEHTTPSOCKET},'+',useHttpApiRegisteringURI{$endif});
try
aHTTPServer.RootRedirectToURI('blog/default'); // redirect / to blog/default
aServer.RootRedirectGet := 'blog/default'; // redirect blog to blog/default
writeln('"MVC Blog Server" launched on port 8092 using ',aHttpServer.HttpServer.ClassName);
...
(starting from sample 30)
Each controller should have its own dedicated interface type, for sure.
Offline
You can create any number of TMVCApplication with different URI for each.
procedure TBlogApplication.Start(aServer: TSQLRestServer);
begin
...
// publish IBlogApplication using Mustache Views (TMVCRunOnRestServer default)
fMainRunner := TMVCRunOnRestServer.Create(Self, nil, 'blog1' { <- aSubURI } );
...
end;
Offline
Each controller should have its own dedicated interface type, for sure.
Not interface type, but method names if you use aSubURI = '', or different aSubURI for each TMVCApplication.
Offline
Excellent. Thanks guys.
It was easier than I thought.
Offline
I also encountered similar problems. After referring to this post, I still don't know how to solve them. I have some controllers in one application. How do I use different methods?
For example , I have a sqlite database , "/user/add" assign to procedure user_add , "/order/create" assign to procedure order_create.
In my code , TSQLHttpServer use to http service , TSQLRestServerDB use to database process . How can TSQLRestServerDB set to multi path to procedure ? Or any other code support it ?
Offline
This post is about MVC web applications, not regular REST services as you try to implement, if I understand correctly.
Maybe I misunderstood this post. But how should I realize my demand?
And thank you for your reply.
Offline
Pages: 1