Jump to content
Yaron

Responding to unspecified entry paths

Recommended Posts

Is it possible to make a sort of "catch all" for all "GET/POST" commands that use a path not specified through mars?

 

For example, I have mars specified to return a page using "http://website.com/rest/info"

However, If the client opens the unspecified "http://website.com/rest/none" path, MARS throws an exception.

 

Instead of the exception, I want to catch all unspecified paths and return an HTML result (and keep a record of the unspecified path in my debug logs).

 

Is this possible?

Edited by Yaron

Share this post


Link to post

Hi @Yaron,

you can register an InvokeError procedure to deal with non-matching URLs, there's a template in Server.Ignition file, line 107 (https://github.com/andrea-magni/MARS/blob/daef64912b04036917cb336c4eee34438fa993a8/Demos/MARSTemplate/Server.Ignition.pas#L107).

 

If you uncomment that registration, you can implement whatever policy using the AActivation argument to access Request and Response objects (you can set the StatusCode, Content and ContentType of the Response object as you like).

 

Sincerely,

Andrea

  • Like 1

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×