1
/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2012 Mohit Srivastava
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
* @file Declare a class HTTPHandler which handles the operations related to HTTP request and response.
28
#include <plugin/json_server/json/json.h>
29
#include <drizzled/plugin.h>
33
* Drizzle Plugin Namespace
35
namespace drizzle_plugin
38
* Json Server Plugin Namespace
44
* used to handles http request and response.
52
* @param json_out an empty json output object.
53
* @param json_in an empty json input object.
54
* @param req the http request object to parse.
56
HttpHandler(Json::Value& json_out,Json::Value json_in,struct evhttp_request *req);
58
* Parse http request and retrieve various http headers.
60
* @return false Success
61
* @return true Failure
65
* Parse input json query and generate input json object.
67
* @param default_schema a string.
68
* @param default_table a string.
69
* @param allow_drop_table a boolean value.
70
* @return false Success.
71
* @return true Failure.
73
bool validate(string &default_schema,string &default_table,bool allow_drop_table);
75
* Send http response back.
77
* @param json_out a Json::Value object.
81
* Generate a http error when table is null.
83
void generateHttpError();
85
* Generate a error occurs using DROP Table command.
87
void generateDropTableError();
89
* Get schema being used.
90
* @return a constant schema string.
92
const char* getSchema() const
97
* Get table being used.
99
* @return a constant table string.
101
const char* getTable() const
106
* Get query being used.
107
* @return a constant query string.
109
const string &getQuery() const
115
* @return a constant id string.
117
const char* getId() const
122
* Get output json object.
123
* @return a constant json object.
125
const Json::Value getOutputJson() const
130
* Get input json object.
131
* @return a constant json object.
133
const Json::Value getInputJson() const
138
* Set Output json object.
139
* @param json_out a Json::Value object.
141
void setOutputJson(Json::Value& json_out)
148
* Stores schema being used.
152
* Stores table being used.
156
* Stores query being used.
160
* Stores id primary key for a dcument.
164
* Stores output json object.
166
Json::Value _json_out;
168
* Stores input json object.
170
Json::Value _json_in;
172
* Stores http response code.
174
int _http_response_code;
176
* Stores http response text.
178
const char *_http_response_text;
180
* Stores http request object.
182
struct evhttp_request *_req;