proxygen
RequestHandlerFactory.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
13 
14 namespace proxygen {
15 
20  public:
22 
28  virtual void onServerStart(folly::EventBase* evb) noexcept = 0;
29 
34  virtual void onServerStop() noexcept = 0;
35 
49  virtual RequestHandler* onRequest(RequestHandler*, HTTPMessage*) noexcept = 0;
50 };
51 
56  public:
57  std::vector<std::unique_ptr<RequestHandlerFactory>> build() {
58  return std::move(chain_);
59  }
60 
61  template <typename T, typename... Args>
63  chain_.push_back(std::make_unique<T>(std::forward<Args>(args)...));
64  return *this;
65  }
66 
67  RequestHandlerChain& addThen(std::unique_ptr<RequestHandlerFactory> h) {
68  chain_.push_back(std::move(h));
69  return *this;
70  }
71 
72  private:
73  std::vector<std::unique_ptr<RequestHandlerFactory>> chain_;
74 };
75 
76 }
#define T(v)
Definition: http_parser.c:233
*than *hazptr_holder h
Definition: Hazptr.h:116
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual RequestHandler * onRequest(RequestHandler *, HTTPMessage *) noexcept=0
std::vector< std::unique_ptr< RequestHandlerFactory > > chain_
RequestHandlerChain & addThen(Args &&...args)
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
virtual void onServerStart(folly::EventBase *evb) noexcept=0
requires E e noexcept(noexcept(s.error(std::move(e))))
virtual void onServerStop() noexcept=0
std::vector< std::unique_ptr< RequestHandlerFactory > > build()
RequestHandlerChain & addThen(std::unique_ptr< RequestHandlerFactory > h)