2
* Licensed to the Apache Software Foundation (ASF) under one
3
* or more contributor license agreements. See the NOTICE file
4
* distributed with this work for additional information
5
* regarding copyright ownership. The ASF licenses this file
6
* to you under the Apache License, Version 2.0 (the
7
* "License"); you may not use this file except in compliance
8
* with the License. You may obtain a copy of the License at
10
* http://www.apache.org/licenses/LICENSE-2.0
12
* Unless required by applicable law or agreed to in writing,
13
* software distributed under the License is distributed on an
14
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
* KIND, either express or implied. See the License for the
16
* specific language governing permissions and limitations
20
#ifndef _THRIFT_TEVHTTP_SERVER_H_
21
#define _THRIFT_TEVHTTP_SERVER_H_ 1
23
#include <boost/shared_ptr.hpp>
27
struct evhttp_request;
29
namespace apache { namespace thrift { namespace async {
31
class TAsyncBufferProcessor;
36
* Create a TEvhttpServer for use with an external evhttp instance.
37
* Must be manually installed with evhttp_set_cb, using
38
* TEvhttpServer::request as the callback and the
39
* address of the server as the extra arg.
40
* Do not call "serve" on this server.
42
TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor);
45
* Create a TEvhttpServer with an embedded event_base and evhttp,
46
* listening on port and responding on the endpoint "/".
47
* Call "serve" on this server to serve forever.
49
TEvhttpServer(boost::shared_ptr<TAsyncBufferProcessor> processor, int port);
53
static void request(struct evhttp_request* req, void* self);
56
struct event_base* getEventBase();
59
struct RequestContext;
61
void process(struct evhttp_request* req);
62
void complete(RequestContext* ctx, bool success);
64
boost::shared_ptr<TAsyncBufferProcessor> processor_;
65
struct event_base* eb_;
69
}}} // apache::thrift::async
71
#endif // #ifndef _THRIFT_TEVHTTP_SERVER_H_