// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #pragma once #include #include "context.h" namespace onnxruntime { namespace server { namespace http = boost::beast::http; // from using HandlerFn = std::function; using ErrorFn = std::function; // This class maintains two lists of regex -> function lists. One for POST requests and one for GET requests // If the incoming URL could match more than one regex, the first one will win. class Routes { public: Routes() = default; ErrorFn on_error; bool RegisterController(http::verb method, const std::string& url_pattern, const HandlerFn& controller); bool RegisterErrorCallback(const ErrorFn& controller); http::status ParseUrl(http::verb method, const std::string& url, /* out */ std::string& model_name, /* out */ std::string& model_version, /* out */ std::string& action, /* out */ HandlerFn& func) const; private: std::vector> post_fn_table; std::vector> get_fn_table; }; } //namespace server } // namespace onnxruntime