#1 2020-12-11 15:34:36

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Error 400 in a bare, hello world MVC project

I tried to test a bare, hello world MVC project in FPC/linux. I created an interface, IBareApplication descendant of IMVCApplication with no extra methods and a class, TBareApplication, descendant of TMVCApplication which implements the IBareApplication. This class has only two methods Start and Default. Start calls only the inherited method and Default is empty. Then I created the Views folder with Default and Error html files, the former contains the hello world message and the latter is a modified copy from the Sample 30.

The main file creates an empty model, an in memory Rest Server and the above application:

  aModel := TSQLModel.Create([],'test');
  try
    aServer := TSQLRestServerFullMemory.Create(aModel);
    try
      aApplication := TBareApplication.Create;
      try
        aApplication.Start(aServer);
        aHTTPServer := TSQLHttpServer.Create('8092',aServer);
        try
          aHTTPServer.RootRedirectToURI('test/default');
          aServer.RootRedirectGet := 'test/default';
          writeln('Running, press ENTER to exit');
          readln;
        finally
...

When I try to access localhost:8092/ it redirects to http://localhost:8092/test/default as expected, with a Json response contains an Error 400/Bad request message. What am I missing here? hmm

Offline

#2 2020-12-15 12:14:21

damiand
Member
From: Greece
Registered: 2018-09-21
Posts: 94

Re: Error 400 in a bare, hello world MVC project

damiand wrote:

Start calls only the inherited method...

I missed one more call after the inherited Start method. This call in its simplest form (without any cache) is:

fMainRunner := TMVCRunOnRestServer.Create(Self);

Offline

Board footer

Powered by FluxBB