In server.hpp, there are some typedefs inside class 'basic_server'

typedef basic_request<Tag> request;
typedef basic_response<Tag> response;


And corresponding typedefs referring to these inside class 'server'

typedef typename basic_server<tags::http_server,Handler>::request
request;
typedef typename basic_server<tags::http_server,Handler>::response
response;

All this is inside the namespace 'http'

I don't pretend to understand the overall design, but since the class
'basic_server' is templated on type 'Handler' as well as type 'Tag', it
seems to me that the types 'request' & 'response' are unnecessarily
coupled to the 'Handler' type.

An example may help explain what I'm trying to say:

In hello_world_server.cpp, we have something like


struct hello_world;
typedef http::server<hello_world> server;
struct hello_world {
   void operator() (server::request const &request, server::response
&response) {}
};

This hello_world handler can *only* be used with a server of type
'http::server<hello_world>', because the request and response types are
defined in terms of the server.  However, the type
'http::server::request' can *only* be type
'http::basic_request<tags::http_server>'.  Note that the request type is
not at all dependent on the type of the handler, 'hello_world'

The result is that my handler can only be used with one certain server,
even though the request type is always
http::basic_request<tags::http_server>.  I know this could be solved
with templated typedefs if they were available, but given that all this
is in the namespace 'http', is there some reason that there couldn't be
a typedef along the lines of

namespace boost { namespace network { namespace http {
typedef basic_request<tags::http_server> request;
} } }

So I could write

struct hello_world {
   void operator() (http::request const &request, http::response
&response) {}
};

And thereby use my handler more generically?

I know I could write something like this

struct hello_world {
   void operator() (http::basic_request<tags::http_server> const
&request, http::basic_response<tags::http_server> &response) {}
};

but that seems a bit excessively clever, seeing as how it's stealing a
typedef from both the parent and grandparent.

Any comment?

Erik

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Cpp-netlib-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cpp-netlib-devel

Reply via email to