Changeset 1084

Show
Ignore:
Timestamp:
06/11/08 15:08:57 (3 months ago)
Author:
kris
Message:

added a GetServlet?, which uses the query string to indicate which method to call

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/net/servlet/Servlet.d

    r1082 r1084  
    1818 
    1919public  import  tango.util.log.Log; 
     20 
     21private import  Util = tango.text.Util; 
    2022 
    2123public  import  tango.net.http.HttpConst, 
     
    284286        void service (IServletRequest request, IServletResponse response) 
    285287        { 
     288                service (request.method, request, response); 
     289        } 
     290 
     291        /********************************************************************** 
     292 
     293                Service implementation for method specific isolation. 
     294 
     295        **********************************************************************/ 
     296 
     297        void service (char[] method, IServletRequest request, IServletResponse response) 
     298        { 
    286299                StopWatch       timer; 
    287300                Metrics*        metric; 
    288301                Handler         handler; 
    289                 char[]          method = request.method; 
    290302 
    291303                // begin timer 
     
    380392 
    381393 
    382  
     394/****************************************************************************** 
     395 
     396        Extends the method servlet with a way to use GET for everything,  
     397        where the dispatch is instead defined via a query-parameter called 
     398        'request'  
     399 
     400******************************************************************************/ 
     401 
     402class GetServlet : MethodServlet 
     403
     404        /********************************************************************** 
     405         
     406 
     407        **********************************************************************/ 
     408 
     409        this (char[] name = null) 
     410        {        
     411                super (name); 
     412        } 
     413 
     414        /********************************************************************** 
     415 
     416                Service implementation for method specific isolation. 
     417 
     418        **********************************************************************/ 
     419 
     420        void service (IServletRequest request, IServletResponse response) 
     421        { 
     422                auto method = request.method; 
     423                auto query = request.uri.getQuery; 
     424                auto index = Util.locatePattern (query, "request="); 
     425 
     426                if (index < query.length) 
     427                    method = query [index+8 .. Util.locate (query, '&', index+8)]; 
     428                 
     429                super.service (method, request, response); 
     430        } 
     431