MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / Server

Class Server

external/httplib.h:916–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

914} // namespace detail
915
916class Server {
917public:
918 using Handler = std::function<void(const Request &, Response &)>;
919
920 using ExceptionHandler =
921 std::function<void(const Request &, Response &, std::exception_ptr ep)>;
922
923 enum class HandlerResponse {
924 Handled,
925 Unhandled,
926 };
927 using HandlerWithResponse =
928 std::function<HandlerResponse(const Request &, Response &)>;
929
930 using HandlerWithContentReader = std::function<void(
931 const Request &, Response &, const ContentReader &content_reader)>;
932
933 using Expect100ContinueHandler =
934 std::function<int(const Request &, Response &)>;
935
936 Server();
937
938 virtual ~Server();
939
940 virtual bool is_valid() const;
941
942 Server &Get(const std::string &pattern, Handler handler);
943 Server &Post(const std::string &pattern, Handler handler);
944 Server &Post(const std::string &pattern, HandlerWithContentReader handler);
945 Server &Put(const std::string &pattern, Handler handler);
946 Server &Put(const std::string &pattern, HandlerWithContentReader handler);
947 Server &Patch(const std::string &pattern, Handler handler);
948 Server &Patch(const std::string &pattern, HandlerWithContentReader handler);
949 Server &Delete(const std::string &pattern, Handler handler);
950 Server &Delete(const std::string &pattern, HandlerWithContentReader handler);
951 Server &Options(const std::string &pattern, Handler handler);
952
953 bool set_base_dir(const std::string &dir,
954 const std::string &mount_point = std::string());
955 bool set_mount_point(const std::string &mount_point, const std::string &dir,
956 Headers headers = Headers());
957 bool remove_mount_point(const std::string &mount_point);
958 Server &set_file_extension_and_mimetype_mapping(const std::string &ext,
959 const std::string &mime);
960 Server &set_default_file_mimetype(const std::string &mime);
961 Server &set_file_request_handler(Handler handler);
962
963 template <class ErrorHandlerFunc>
964 Server &set_error_handler(ErrorHandlerFunc &&handler) {
965 return set_error_handler_core(
966 std::forward<ErrorHandlerFunc>(handler),
967 std::is_convertible<ErrorHandlerFunc, HandlerWithResponse>{});
968 }
969
970 Server &set_exception_handler(ExceptionHandler handler);
971 Server &set_pre_routing_handler(HandlerWithResponse handler);
972 Server &set_post_routing_handler(Handler handler);
973

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected