MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / Server

Class Server

examples/server/httplib.h:661–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659void default_socket_options(socket_t sock);
660
661class Server {
662public:
663 using Handler = std::function<void(const Request &, Response &)>;
664
665 using ExceptionHandler =
666 std::function<void(const Request &, Response &, std::exception_ptr ep)>;
667
668 enum class HandlerResponse {
669 Handled,
670 Unhandled,
671 };
672 using HandlerWithResponse =
673 std::function<HandlerResponse(const Request &, Response &)>;
674
675 using HandlerWithContentReader = std::function<void(
676 const Request &, Response &, const ContentReader &content_reader)>;
677
678 using Expect100ContinueHandler =
679 std::function<int(const Request &, Response &)>;
680
681 Server();
682
683 virtual ~Server();
684
685 virtual bool is_valid() const;
686
687 Server &Get(const std::string &pattern, Handler handler);
688 Server &Post(const std::string &pattern, Handler handler);
689 Server &Post(const std::string &pattern, HandlerWithContentReader handler);
690 Server &Put(const std::string &pattern, Handler handler);
691 Server &Put(const std::string &pattern, HandlerWithContentReader handler);
692 Server &Patch(const std::string &pattern, Handler handler);
693 Server &Patch(const std::string &pattern, HandlerWithContentReader handler);
694 Server &Delete(const std::string &pattern, Handler handler);
695 Server &Delete(const std::string &pattern, HandlerWithContentReader handler);
696 Server &Options(const std::string &pattern, Handler handler);
697
698 bool set_base_dir(const std::string &dir,
699 const std::string &mount_point = std::string());
700 bool set_mount_point(const std::string &mount_point, const std::string &dir,
701 Headers headers = Headers());
702 bool remove_mount_point(const std::string &mount_point);
703 Server &set_file_extension_and_mimetype_mapping(const std::string &ext,
704 const std::string &mime);
705 Server &set_file_request_handler(Handler handler);
706
707 Server &set_error_handler(HandlerWithResponse handler);
708 Server &set_error_handler(Handler handler);
709 Server &set_exception_handler(ExceptionHandler handler);
710 Server &set_pre_routing_handler(HandlerWithResponse handler);
711 Server &set_post_routing_handler(Handler handler);
712
713 Server &set_expect_100_continue_handler(Expect100ContinueHandler handler);
714 Server &set_logger(Logger logger);
715
716 Server &set_address_family(int family);
717 Server &set_tcp_nodelay(bool on);
718 Server &set_socket_options(SocketOptions socket_options);

Callers

nothing calls this directly

Calls 1

stringFunction · 0.70

Tested by

no test coverage detected