// TJP COPYRIGHT HEADER #pragma once #include "Server.h" #include "Component.h" #include "Types.hpp" #include #include #include #include #include #include "as_future.hpp" namespace tjp::core::http { struct Server { virtual ~Server() {} virtual void add( const StrongPtr &component, const String &urlPrefix = {} ) = 0; template void addAll(Args && ...args) { (add(std::forward(args)), ...); } virtual void setNumThreads(size_t) = 0; virtual void start(const String &bindTo, int port) = 0; virtual void run(const String &bindTo, int port) = 0; virtual void stop() = 0; virtual bool isRunning() = 0; virtual void bind( const Method &method, Matcher &&matcher, FutureHandler && ) = 0; void bind( const Method &method, const Pattern &pattern, FutureHandler &&handler ) { bind( method, match_regex(String(pattern)), std::move(handler) ); } template void bind_with( const Method &method, Matcher matcher, F &&f ) { bind( method, std::move(matcher), as_future( std::forward(f) ) ); } template void bind_with( const Method &method, const Pattern &pattern, F &&f ) { bind_with( method, match_regex(String(pattern)), std::forward(f) ); } }; } // namespace #ifdef TJP_CORE_HEADER_ONLY #include "Server.cpp" #endif