initial commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
build
|
||||
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
project (auth_service)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
include_directories(./src/lib)
|
||||
|
||||
# find_package(cpp-httplib REQUIRED)
|
||||
|
||||
add_executable(auth_service src/auth_service.cpp)
|
||||
# target_link_libraries(auth_service cpp-httplib)
|
||||
@@ -0,0 +1,22 @@
|
||||
#include <iostream>
|
||||
#include "libs/httplib.h"
|
||||
#include "libs/json.hpp"
|
||||
#include <fstream>
|
||||
|
||||
int main() {
|
||||
httplib::Server srv;
|
||||
|
||||
srv.Get("/api/token", [](const httplib::Request& request, httplib::Response& response) {
|
||||
response.set_content("{\"token\":\"qwerty\"}", "application/json");
|
||||
});
|
||||
|
||||
srv.Get("/api/users", [](const httplib::Request& request, httplib::Response& response) {
|
||||
std::ifstream usersfile("users.json");
|
||||
nlohmann::json usersdata = nlohmann::json::parse(usersfile);
|
||||
usersfile.close();
|
||||
response.set_content(usersdata.dump(), "application/json");
|
||||
});
|
||||
|
||||
srv.listen("localhost", 43243);
|
||||
return 0;
|
||||
}
|
||||
+9788
File diff suppressed because it is too large
Load Diff
+24766
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user