Now uses std::regex instead of boost::regex
This commit is contained in:
parent
7fb40a1be9
commit
78d68b063b
2 changed files with 7 additions and 21 deletions
|
|
@ -2,25 +2,11 @@ cmake_minimum_required (VERSION 2.8.8)
|
||||||
project (Simple-Web-Server)
|
project (Simple-Web-Server)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
|
||||||
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
|
||||||
message(FATAL_ERROR "GCC version >=4.8 required.")
|
|
||||||
endif()
|
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
|
|
||||||
message(FATAL_ERROR "Clang version >=3.3 required.")
|
|
||||||
endif()
|
|
||||||
elseif (MSVC14) #TODO: What about other MSVC versions?
|
|
||||||
else()
|
|
||||||
message(WARNING "Your compiler (${CMAKE_CXX_COMPILER_ID}) has not been tested on this project. Only Clang and GCC has been tested. Please report any problems at the project page on GitHub.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
include_directories(.)
|
include_directories(.)
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
find_package(Boost 1.53.0 COMPONENTS regex system thread filesystem date_time REQUIRED)
|
find_package(Boost 1.53.0 COMPONENTS system thread filesystem date_time REQUIRED)
|
||||||
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
|
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
#define SERVER_HTTP_HPP
|
#define SERVER_HTTP_HPP
|
||||||
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
#include <regex>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -75,7 +75,7 @@ namespace SimpleWeb {
|
||||||
|
|
||||||
std::unordered_multimap<std::string, std::string, ihash, iequal_to> header;
|
std::unordered_multimap<std::string, std::string, ihash, iequal_to> header;
|
||||||
|
|
||||||
boost::smatch path_match;
|
std::smatch path_match;
|
||||||
|
|
||||||
std::string remote_endpoint_address;
|
std::string remote_endpoint_address;
|
||||||
unsigned short remote_endpoint_port;
|
unsigned short remote_endpoint_port;
|
||||||
|
|
@ -111,7 +111,7 @@ namespace SimpleWeb {
|
||||||
std::function<void(const std::exception&)> exception_handler;
|
std::function<void(const std::exception&)> exception_handler;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::pair<std::string, std::vector<std::pair<boost::regex,
|
std::vector<std::pair<std::string, std::vector<std::pair<std::regex,
|
||||||
std::function<void(std::shared_ptr<typename ServerBase<socket_type>::Response>, std::shared_ptr<typename ServerBase<socket_type>::Request>)> > > > > opt_resource;
|
std::function<void(std::shared_ptr<typename ServerBase<socket_type>::Response>, std::shared_ptr<typename ServerBase<socket_type>::Request>)> > > > > opt_resource;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
@ -132,7 +132,7 @@ namespace SimpleWeb {
|
||||||
it=opt_resource.begin()+(opt_resource.size()-1);
|
it=opt_resource.begin()+(opt_resource.size()-1);
|
||||||
it->first=res_method.first;
|
it->first=res_method.first;
|
||||||
}
|
}
|
||||||
it->second.emplace_back(boost::regex(res.first), res_method.second);
|
it->second.emplace_back(std::regex(res.first), res_method.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -335,8 +335,8 @@ namespace SimpleWeb {
|
||||||
for(auto& res: opt_resource) {
|
for(auto& res: opt_resource) {
|
||||||
if(request->method==res.first) {
|
if(request->method==res.first) {
|
||||||
for(auto& res_path: res.second) {
|
for(auto& res_path: res.second) {
|
||||||
boost::smatch sm_res;
|
std::smatch sm_res;
|
||||||
if(boost::regex_match(request->path, sm_res, res_path.first)) {
|
if(std::regex_match(request->path, sm_res, res_path.first)) {
|
||||||
request->path_match=std::move(sm_res);
|
request->path_match=std::move(sm_res);
|
||||||
write_response(socket, request, res_path.second);
|
write_response(socket, request, res_path.second);
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue