HTTPServlet.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2009 Savarese Software Research Corporation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * https://www.savarese.com/software/ApacheLicense-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00022 #ifndef __SSRC_WSPR_FCGI_HTTP_SERVLET_H 00023 #define __SSRC_WSPR_FCGI_HTTP_SERVLET_H 00024 00025 #include <ssrc/wispers/fcgi/HTTPResponse.h> 00026 #include <ssrc/wispers/fcgi/HTTPRequest.h> 00027 00028 __BEGIN_NS_SSRC_WSPR_FCGI 00029 00030 template<typename RequestType = HTTPRequest, 00031 typename ResponseType = HTTPResponse> 00032 class HTTPServlet { 00033 public: 00034 typedef RequestType request_type; 00035 typedef ResponseType response_type; 00036 typedef boost::shared_ptr<request_type> request_ptr; 00037 typedef boost::shared_ptr<response_type> response_ptr; 00038 00039 protected: 00040 typedef void (HTTPServlet::* request_function_ptr)(const request_ptr &, 00041 response_ptr &); 00042 static const request_function_ptr RequestMethodHandler[MethodNum]; 00043 00044 public: 00045 virtual ~HTTPServlet() { } 00046 00047 virtual 00048 void http_delete(const request_ptr & request, response_ptr & response) { 00049 response->send_error(StatusMethodNotAllowed); 00050 } 00051 00052 virtual 00053 void http_get(const request_ptr & request, response_ptr & response) { 00054 response->send_error(StatusMethodNotAllowed); 00055 } 00056 00057 virtual 00058 void http_head(const request_ptr & request, response_ptr & response) { 00059 response->send_error(StatusMethodNotAllowed); 00060 } 00061 00062 virtual 00063 void http_options(const request_ptr & request, response_ptr & response) { 00064 response->send_error(StatusMethodNotAllowed); 00065 } 00066 00067 virtual 00068 void http_post(const request_ptr & request, response_ptr & response) { 00069 response->send_error(StatusMethodNotAllowed); 00070 } 00071 00072 virtual 00073 void http_put(const request_ptr & request, response_ptr & response) { 00074 response->send_error(StatusMethodNotAllowed); 00075 } 00076 00077 virtual 00078 void http_trace(const request_ptr & request, response_ptr & response) { 00079 response->send_error(StatusMethodNotAllowed); 00080 } 00081 }; 00082 00083 template<typename RequestType, typename ResponseType> 00084 const typename HTTPServlet<RequestType, ResponseType>::request_function_ptr 00085 HTTPServlet<RequestType, ResponseType>::RequestMethodHandler[MethodNum] = { 00086 &HTTPServlet::http_delete, 00087 &HTTPServlet::http_get, 00088 &HTTPServlet::http_head, 00089 &HTTPServlet::http_options, 00090 &HTTPServlet::http_post, 00091 &HTTPServlet::http_put, 00092 &HTTPServlet::http_trace 00093 }; 00094 00095 __END_NS_SSRC_WSPR_FCGI 00096 00097 #endif
Copyright © 2006-2011 Savarese Software Research Corporation. All rights reserved.