Project

General

Profile

Custom response handler for WServer

Added by Somsubhra Sharangi almost 12 years ago

Hi,

I am trying to add Wt server to an existing application and my requirement is that the application create custom responses for some URL requests.

The handleRequest() method in WResource class is similar to what I am looking for but it requires me to register the resource(or URL) with the server. Is there any way to do it without registering the URL( e.g. for unknown URLs). I want to receive all incoming requets, process 'some' URLs according to my application logic, and let Wt server process the other URLs as per normal processing.

e.g.

 handleAllRequests(req){
  if(req.URL match ABC)
   appresponse = myresponse(req);
  else
   appresponse = Wt_normal_response(req);
  response.out() << appresponse;
 }

The WApplication approach means only requests from Wt client will be handled by the server, so this does not address my requirement. In my case the incoming requests can be generated by any browser or other command line HTTP tools like wget or curl. Please suggest if there are any other approaches to achieve this.

Regards,

Som


Replies (2)

RE: Custom response handler for WServer - Added by Wim Dumon almost 12 years ago

I'm not aware of a method that could show a popup on a 404 error.

However, you can customize the 404 page with the built-in httpd. Make sure that the ---errroot parameter is set correctly, and then look in StockReply.C for the proper name of the error page to be customized. For 404 errors, that is 404-not-found.html. Wt will serve this file instead of a default 404 error, if it can read it.

Wim.

RE: Custom response handler for WServer - Added by Somsubhra Sharangi almost 12 years ago

Hi Wim,

Looks like this response is for another post.

Regards,

Som

    (1-2/2)