matt-42 / lithium Goto Github PK
View Code? Open in Web Editor NEWEasy to use C++17 HTTP Server with no compromise on performances. https://matt-42.github.io/lithium
Home Page: https://matt-42.github.io/lithium
License: MIT License
Easy to use C++17 HTTP Server with no compromise on performances. https://matt-42.github.io/lithium
Home Page: https://matt-42.github.io/lithium
License: MIT License
Dear Matt,
I have encountered some difficulties in building the package, probably because I don't have much experience in introspection in C++.
It is unbuntu 19, with gcc-9.3
[main] Building folder: lithium
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/lind/gits/lithium/build --config Debug --target test_symbol -- -j 10
[build] [ 50%] Built target li_symbol_generator
[build] [ 50%] Built target single_headers
[build] [ 50%] Built target symbols_generation
[build] [ 75%] Building CXX object libraries/symbol/CMakeFiles/test_symbol.dir/tests/test.cc.o
[build] In file included from /home/lind/gits/lithium/libraries/symbol/tests/test.cc:4:
[build] /home/lind/gits/lithium/build/include/li/sql/mysql_async_wrapper.hh: In member function ‘auto li::mysql_functions_non_blocking<Y>::mysql_fetch_row(std::shared_ptr<int>, A&& ...)’:
[build] /home/lind/gits/lithium/build/include/li/sql/mysql_async_wrapper.hh:83:45: error: ‘::mysql_fetch_row_start’ has not been declared; did you mean ‘mysql_fetch_row’?
[build] 83 | LI_MYSQL_NONBLOCKING_WRAPPER(mysql_error, mysql_fetch_row
...
...
I have also tried to manually run li_symbol_generator in project root but it doesn't change anything.
Where should the symbol mysql_fetch_row_start
be placed? Should it be in some symbols.hh
?
Hi! Trying to establish connection with remote PG server got error "Warning: cannot connect to the postgresql server X.X.X.X: could not send SSL negotiation packet: Resource temporarily unavailable". Same result for "li run main.cc" and local CMake build. pgcli works fine with the same connection parameters.
auto db = pgsql_database(
s::host = "xxx.xxx.xxx.xxx", // Hostname or ip of the database server
s::database = "my-services", // Database name
s::user = "admin", // Username
s::password = "admin", // Password
s::port = 31357, // Port
s::charset = "utf8", // Charset
// Only for async connection, specify the maximum number of SQL connections per thread.
s::max_async_connections_per_thread = 200,
// Only for synchronous connection, specify the maximum number of SQL connections
s::max_sync_connections = 2000);
auto countries_orm = sql_orm_schema(db, "sys.country")
.fields(
s::id(s::auto_increment, s::primary_key) = int(),
s::code = std::string(),
s::code_3 = std::string(),
s::code_dig = std::string(),
s::name = std::string(),
s::name_engl = std::string(),
s::note = std::string()
);
auto countries = countries_orm.connect();
cd /home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks && /bin/c++ -DBOOST_ALL_NO_LIB -DBOOST_CONTEXT_DYN_LINK -DBOOST_FILESYSTEM_DYN_LINK -I/home/nicole/software/cpp/lithium-master/include -I/usr/include/mysql -I/opt/pgsql-11/include/server -isystem /include -std=gnu++17 -o CMakeFiles/bench.dir/bench.cc.o -c /home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc
/home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc: In function ‘float tune_n_sql_connections(std::string, int, int)’:
/home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc:192:18: error: invalid initialization of reference of type ‘const std::vector&’ from expression of type ‘int’
192 | http_benchmark(512, 1, 1000, port, http_req);
| ^~~
In file included from /home/nicole/software/cpp/lithium-master/include/li/http_backend/http_backend.hh:24,
from /home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc:1:
/home/nicole/software/cpp/lithium-master/include/li/http_backend/http_benchmark.hh:111:46: note: in passing argument 1 of ‘float li::http_benchmark(const std::vector&, int, int, std::string_view)’
111 | float http_benchmark(const std::vector& sockets, int NTHREADS, int duration_in_ms,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
/home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc:201:38: error: invalid initialization of reference of type ‘const std::vector&’ from expression of type ‘int’
201 | float req_per_s = http_benchmark(512, 1, 400, port, http_req);
| ^~~
In file included from /home/nicole/software/cpp/lithium-master/include/li/http_backend/http_backend.hh:24,
from /home/nicole/software/cpp/lithium-master/libraries/http_backend/benchmarks/bench.cc:1:
/home/nicole/software/cpp/lithium-master/include/li/http_backend/http_benchmark.hh:111:46: note: in passing argument 1 of ‘float li::http_benchmark(const std::vector&, int, int, std::string_view)’
111 | float http_benchmark(const std::vector& sockets, int NTHREADS, int duration_in_ms,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
make[2]: *** [libraries/http_backend/benchmarks/CMakeFiles/bench.dir/build.make:66: libraries/http_backend/benchmarks/CMakeFiles/bench.dir/bench.cc.o] Error 1
Is there a way to determine the IP address of the client connected to the http backend? I am aware this can be spoofed, or masked behind proxy etc., but I am trying to build some geographical analytics around visitor data.
I do look for x-real-ip
or x-forwarded-for
headers, but want a fallback if not available via header.
Hello and thanks for the library and documentation.
Today I tested a cmake-based project where I attempted to compartmentalize the codebase to define different api endpoints in different files. While doing so, I ran into difficulties while importing lithium_http_backend.hh.
There were "multiple definition" errors for the following variable and function definitions:
`li::make_json_error(char const*)';
`li::json_no_error()';
`li::detect_encoding(char, char, char, char)';
`li::async_fiber_context::epoll_mod(int, int)';
`li::async_fiber_context::defer_fiber_resume(int)';
`li::async_fiber_context::reassign_fd_to_fiber(int, int)';
`li::url_unescape(std::basic_string_view<char, std::char_traits<char> >)';
`li::http_async_impl::date_buf_size';
`li::http_async_impl::date_buf';
`li::http_benchmark_impl::error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)';
`li::http_benchmark_close(std::vector<int, std::allocator<int> > const&)';
`li::generate_secret_tracking_id[abi:cxx11]()';
`li::async_fiber_context::epoll_add(int, int)';
`li::async_fiber_context::defer(std::function<void ()> const&)';
`li::http_benchmark_connect(int, int)';
`li::http_benchmark(std::vector<int, std::allocator<int> > const&, int, int, std::basic_string_view<char, std::char_traits<char> >)';
`li::http_async_impl::static_files[abi:cxx11]';
`li::serve_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string_view<char, std::char_traits<char> >, li::http_res>
`li::make_url_parser_info[abi:cxx11](std::basic_string_view<char, std::char_traits<char> >)';
`TLS init function for li::http_async_impl::static_files[abi:cxx11]';
`li::ssl_context::openssl_initialized';
I manually added "inline" designations to these problematic variables and functions in the "compiled" .hh file. It compiled, and the program seems to work okay, but this is of course a horrible hack and not sustainable.
Am I using the library outside of its intended use practices or was this a bug?
Thank you
How to get all rows from table using sql_orm ? Please guide me here
error: 'struct li::mysql_result<li::mysql_functions_blocking>' has no member named 'map' 29 | connection("Select id,time from items_table;").map([&] (std::string id, std::string time) {
Getting the above error
Thanks,
adibro500
Hello,
I am trying out the JSON library to use with a Grafana JSON datasource project I am starting. I set up some simple structs to model the data as described at https://grafana.com/grafana/plugins/grafana-simple-json-datasource and started a simple unit test for parsing.
With the first Query API sample payload, I am getting only partial results. I get the panelId
and range
parts, but nothing after. Wondering what I am missing.
GIVEN("Sample query from grafana documentation")
{
const auto json = R"({
"panelId": 1,
"range": {
"from": "2016-10-31T06:33:44.866Z",
"to": "2016-10-31T12:33:44.866Z",
"raw": {
"from": "now-6h",
"to": "now"
}
},
"rangeRaw": {
"from": "now-6h",
"to": "now"
},
"interval": "30s",
"intervalMs": 30000,
"targets": [
{ "target": "upper_50", "refId": "A", "type": "timeserie" },
{ "target": "upper_75", "refId": "B", "type": "timeserie" }
],
"adhocFilters": [
"key": "City"
"operator": "=",
"value": "Berlin"
]
"format": "json",
"maxDataPoints": 550
})";
WHEN("Parsing query")
{
auto query = spt::model::Query{};
auto obj = li::json_object( s::panelId,
s::range = li::json_object( s::from, s::to, s::raw = li::json_object( s::from, s::to ) ),
s::rangeRaw = li::json_object( s::from, s::to ),
s::interval, s::intervalMs,
s::targets = li::json_vector( s::target, s::refId, s::type ),
s::adhocFilters = li::json_vector( s::key, s::value ),
s::format, s::maxDataPoints );
obj.decode( json, query );
THEN("Query structure populated")
{
REQUIRE(query.panelId == 1);
REQUIRE(query.range.from == "2016-10-31T06:33:44.866Z");
REQUIRE(query.range.to == "2016-10-31T12:33:44.866Z");
REQUIRE(query.targets.size() == 2);
REQUIRE(query.interval == "30s");
REQUIRE(query.format == "json");
REQUIRE(query.maxDataPoints == 550);
}
THEN("Serialise structure back to JSON")
{
std::cout << obj.encode( query ) << '\n';
}
}
{"panelId":1,"range":{"from":"2016-10-31T06:33:44.866Z","to":"2016-10-31T12:33:44.866Z","raw":{"from":"now-6h","to":"now"}},"rangeRaw":{"from":"","to":""},"interval":"","intervalMs":0,"targets":[],"adhocFilters":[],"format":"","maxDataPoints":0}
On a related note, is it possible to use std::optional<custom struct>
? When I tried to make rangeRaw
an optional, I get a compiler error about missing error
:
lithium_json.h:626:58: error: no member named 'error' in 'li::CANNOT_FIND_REQUESTED_MEMBER_IN_TYPE<s::from_t, std::__1::optional<spt::model::RangeRaw> &>'
return CANNOT_FIND_REQUESTED_MEMBER_IN_TYPE<S, T>::error;
For the database layer, I am currently weighing up ODB, Oat++, SOCI, cppdb, and sqlpp11 [if sqlpp adds support for CREATE TABLE
]. Also drogon seem to have its own ORM layer, but with only PostgreSQL and MySQL support I'm a little worried from a testing and server-less perspective (really would be nice to see support for an embedded database like SQLite). lithium (here) looks good, but the lack of Windows support is a turnoff (you mention you're waiting for a bugfix in MSVC, link? - Maybe I'll try fixing?).
For the REST API layer I haven't started investigating, although I do remember actix being dethroned and the drogon C++ framework taking its place. Lithium (here) winning overall.
I am planning to use LLVM (clang, libclang, libtooling) to synchronise [bidirectionally] OpenAPI with C++ code. I've done the same in Python, and WiP for Rust, Swift, Java, Kotlin, and TypeScript.
With my compiler driven approach, I expect people to be able to rapidly produce REST API + db backends with full test and doc coverage, and be able to immediately translate the interfaces across language boundaries (e.g., to frontends, or to rewrite a slow-performing Python backend in C++ or Rust).
Currently focussing on the non-Turing-complete as aspect of this, translating just the interfaces, tests, docs, defaults, and types.
I am writing tools to allow engineers to develop faster, and with higher quality. Will only target one ORM and one REST API layer for C++, at least in the short-term.
So my question is, and I understand that posting here will provide a heavily biased answer, how do I decide between the various C++ frameworks?
Thanks
How to use the lithium li_symbol_generator without cmake ? Can you provide an example on this ?
Thanks,
adibro500
Bonjour,
I'am following the instruction from lithium, with the hello_world example.
However, when I run li run ./main.cc it return :
--network host
CMake Error in CMakeLists.txt:
cmListFileCache: error can not open file.
-- Configuring incomplete, errors occurred!
CMake Error: Cannot open file for write: /build/CMakeCache.txt.tmp
CMake Error: : System Error: Permission denied
CMake Error: Unable to open cache file for save. /build/CMakeCache.txt
CMake Error: : System Error: Permission denied
When I run the command with sudo, I have the same issue.
I'am on Fedora Linux 35 (Workstation Edition) x86_64, with Linux kernel 5.15.16-200.fc35.x86_64
What can I do ?
Thank you
Loïc
Hey, I noticed a memory leak when a buffer containing malformed JSON is decoded. It appears that the make_json_error method allocates a new std::ostringstream that is never deleted. Seems like it would be an easy fix to use std::unique_ptr instead of a raw pointer for the error_stream.
Hi,
Does the library support HTTP/2 ?
Thanks,
Himanshu
Trying to compile I get the folloing error message:
...lithium\single_headers/lithium_http_client.hh(591,87): error C3543: 'metamap<M1,Ms...>::Ms::_iod_value_type &&': does not contain a parameter pack
...lithium\single_headers/lithium_http_client.hh(603): message : see reference to class template instantiation 'li::metamap<M1,Ms...>' being compiled
It's the same error with the single header libs and the lithium package cmake build.
Help highly appreciated.
Thank You! Reinhard
When we tried to use the lithium library with MySQL we suddenly had reproducible crashes after loading rows and strings in a certain order. After some time, with the help of the Address Sanitizier, we found out, that the library causes use-after-free errors.
I am not sure how many of the resize() places are at fault, but we were able to 100% prove that this line is causing some of the use-after-free errors:
https://github.com/matt-42/lithium/blob/master/libraries/sql/sql/mysql_statement.hh#L209
What happens? You are binding the buffers to MySQL/MariaDB. Then you resize the string, and whenever this causes the underlying data buffer to reallocate, we get use-after-free. The new data array is written into b[i].buffer but MySQL will still use the old buffer, I think you have to mysql_stmt_bind_result again for every buffer change or something like that.
First, wanted to thank you for offering this tool to the community. I've been interested since I saw it win the TechEmpower Benchmark (Congratulations!). I am admittedly a bit rusty with my C++, so I may be missing something obvious. I ran the CLI/docker install and it worked great the first time, but complained about the port being already in use on subsequent runs. I can go back to that method if you suggest. I decided to try the local install on a new debian buster install.
I stumbled on the prerequisites needed, but I think I got past that with this:
apt-get install libcurl4-openssl-dev
apt-get install libboost-all-dev
I also had to modify the install.sh g++ command, adding " -lstdc++fs" in two places to get it to build, guessing it is a debian quirk related to the filesystem library.
g++ -O3 -DNDEBUG -lstdc++fs -std=c++17 $DIR/libraries/symbol/symbol/symbol_generator.cc -o $PREFIX/bin/li_symbol_generator -lstdc++fs
Then I tried a fresh project with a copy of the hello_world script in my_api.cc (to follow the cmake_project_template):
#include "lithium_http_server.hh"
int main() {
// Define an api with one HTTP GET route.
li::http_api api;
api.get("/hello_world") = [&](li::http_request& request, li::http_response& response) {
response.write("hello world.");
};
// Start a http server.
li::http_serve(api, 12345);
}
and the CMakeLists.txt from the cmake_project_template, removing the mysql and sqllite
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 17)
find_package(CURL REQUIRED)
find_package(Threads REQUIRED)
find_package(PostgreSQL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Boost REQUIRED context)
include_directories(${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${PostgreSQL_INCLUDE_DIRS})
set(LIBS ${CURL_LIBRARIES}
${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}
${PostgreSQL_LIBRARIES} ${OPENSSL_LIBRARIES})
# Directory where lithium headers are located if not in the default include path.
include_directories($ENV{HOME}/local/include)
add_custom_target(symbols_generation COMMAND li_symbol_generator ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(my_api my_api.cc)
add_dependencies(my_api symbols_generation)
target_link_libraries(my_api ${LIBS})
Then ran
mkdir build
cd build
cmake ..
make
but unfortunately I receive this error message:
[ 0%] Built target symbols_generation
[ 50%] Building CXX object CMakeFiles/my_api.dir/my_api.cc.o
In file included from /home/brandon/proj/li-test-proj/my_api.cc:1:
/usr/local/include/lithium_http_server.hh: In instantiation of ‘auto li::http_serve(li::api<li::http_request, li::http_response>, int, O ...) [with O = {}]’:
/home/brandon/proj/li-test-proj/my_api.cc:12:28: required from here
/usr/local/include/lithium_http_server.hh:6753:5: error: ‘this’ is not a constant expression
if constexpr (has_key(options, s::ssl_key))
^~
/usr/local/include/lithium_http_server.hh:6755:28: error: non-constant condition for static assertion
static_assert(has_key(options, s::ssl_certificate), "You need to provide both the ssl_certificate option and the ssl_key option.");
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/lithium_http_server.hh:6755:28: error: ‘this’ is not a constant expression
/usr/local/include/lithium_http_server.hh:6756:37: error: ‘const struct li::metamap<>’ has no member named ‘ssl_key’
std::string ssl_key = options.ssl_key;
~~~~~~~~^~~~~~~
/usr/local/include/lithium_http_server.hh:6757:38: error: ‘const struct li::metamap<>’ has no member named ‘ssl_certificate’
std::string ssl_cert = options.ssl_certificate;
~~~~~~~~^~~~~~~~~~~~~~~
/usr/local/include/lithium_http_server.hh:6759:7: error: ‘this’ is not a constant expression
if constexpr (has_key(options, s::ssl_ciphers))
^~
/usr/local/include/lithium_http_server.hh:6761:31: error: ‘const struct li::metamap<>’ has no member named ‘ssl_ciphers’
ssl_ciphers = options.ssl_ciphers;
~~~~~~~~^~~~~~~~~~~
make[2]: *** [CMakeFiles/my_api.dir/build.make:63: CMakeFiles/my_api.dir/my_api.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/my_api.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
I wanted to see if you could offer any suggestions as to what I did wrong?
Hi @matt-42, if there are existing websites or APIs using lithium (demos, examples, production apps, etc.) could the README include a list of these? Any that are open source would especially be great, too!
Make sure using MongoDB with Lithium is feasible and add a MongoDB ORM implementation.
When I going to install lithium locally, I got an error on cmake command.
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
X86 detected
CMake Error at /usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find MYSQL (missing: MYSQL_LIBRARY MYSQL_INCLUDE_DIR)
Call Stack (most recent call first):
/usr/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
cmake/FindMYSQL.cmake:96 (find_package_handle_standard_args)
CMakeLists.txt:12 (find_package)
-- Configuring incomplete, errors occurred!
I have looked to the extent limited by my knowledge. But does anyone know why I get a segfault 11 when I try to access a file larger than 100KB? Perhaps with two extensions like scripts.bundle.js
or widgets.min.css
?
Here is my code snippet
int main(int, char**) {
li::http_api api;
api.get("/{{path...}}") = [&](li::http_request& request, li::http_response& response){
response.write("hey it works");
};
api.add_subapi("/assets", li::serve_directory("./static/assets"));
li::http_serve(api, 8080);
}
Hello Matthieu,
we found your library for a project where we needed a MySQL connection and loving it so far. While looking at the code I noticed following code line: https://github.com/matt-42/lithium/blob/master/libraries/sql/sql/mysql.hh#L63
Isn't this unreachable code and maybe a memory leak or am I missing some macro magic? :D
kind regards, Kira
Support mysql query pipelining.
It is still a feature request in the MariaDB jira. Let's wait until it is implemented.
More info here: https://jira.mariadb.org/browse/CONC-478
With recent additions in C++20 it is possible to write type-level compile-time routes that will accept only parameters of valid type, like this:
using AllPosts = Route< Slug<"blog">, Slug<"posts"> >;
using SinglePost = Route< Slug<"blog">, Slug<"posts">, Capture<int> >;
std::cout << "allPosts = " << AllPosts::toString() << std::endl;
// -> /blog/posts
// std::cout << "singlePost = " << SinglePost::toString() << std::endl;
// invalid path, compilation error
std::cout << "singlePost = " << SinglePost::toString(42) << std::endl;
// -> /blog/posts/42
Here is the proof of concept: https://gist.github.com/stiff/27607ddeb4da590d915423ba6779f18e . Sorry for some obvious room for optimisation :)
Think it's also possible to parse incoming requests in similar manner, is there a chance that'll get into Lithium, so we could define all routes in one place and get compile-time validation that they all genereated and handled just as specified?
Hello,
I'm investigating this library and can't find the way how to implement file streaming with it.
Let's assume huge file is stored in another storage, so I want to use own implementation of file stream, that implements (open/seek/read/write), which then can be used by a framework to get/send chunks of bytes to requestor of this file.
Is this possible with the current state?
Hi,
I attempted to add lithium as a git submodule to a project, however it seems this workflow isn't well supported. Could this workflow be added ?
Thanks
Hey Matt, I am really interested to use lithium as back end in our stack. Could You confirm that the DB function You provided is already using DB connection pooling?
auto connection = database.connect();
CORS working only in get method APIs.
Even if i do: Access-Control-Allow-Origin
in post requests, I still get CORS error.
Access to XMLHttpRequest at 'http://localhost:8000/api/edit/post' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Thanks,
adibro500
I'm looking through the code to try find a work around for this, but if you have any ideas I'd appreciate it.
As far as I can tell, the only way to get a home page to load on just the plain url is to pass an empty string to the get method like this.
li::http_api api;
api.get("") = [&](li::http_request& request, li::http_response& response) {
response.write("hello world.");
};
That works just fine so no problem there. However, when you add a subapi this gets removed or overwritten some how and you get the error.
Route / does not exist.
This wouldn't be a huge problem except I'm trying to add a static files directory
api.add_subapi("/root", serve_directory("/path/to/the/directory/to/serve"));
Installing the framework via CMake, the symbol generator utility is built, under lithium/build/libraries/symbols/li_symbol_generator
, but the target not installed.
I tried to call the custom target with make symbol_generation
but without success.
This is a little issue, but on the introduction page "duplicate" is written like this: "dupplicate".
According to dictionaries like the cambridge dictionary this word is written with only one "p".
I hope this helps a little bit.
It would lift the library to the next level.
Windows Server 2019 is perfectly capable for server programs!
Hi,
I am using longtext in my sql having several thousands long amino acid sequences. But using lithium orm find_one() the result contains only the first 100 character of them. I dag into your code and founded the length of mysql results string is limited to 100 character, e.g in sql/internal/mysql_bind.hh line 111
It has any reason? May I rewrite v.resize(100) to v.resize(*real_length) ?
Thanks.
In line 48, you new drt_node, but I can't find the place you delete them.
else
{
auto new_node = new drt_node();
children_.insert({k, new_node});
return new_node->find_or_create(r, c);
}
Hi,
I'm very curious about the overall design and implementation of Lithium, but getting my head around it is getting quite difficult, how come there are barely any code comments or some sort of naming patterns to make it a bit more readable?
Also, is there some overall bird's eye view design somewhere?
Wouldn't improving that also improve other people contributing?
cheers
Are there any performance benchmarks for lithium? Something like this would be cool: https://www.grandmetric.com/2020/08/10/python-rest-frameworks-performance-comparison/
Please provide an example to implement https.
Thanks,
adibro
We could have a common test suite for all RDBMS. and maybe add specific tests for each one.
I am getting an error when attempting to compile the basic hello world example:
/Users/wolf/Development/include/lithium_http_server.hh:53:10: fatal error: 'sys/sendfile.h' file not found
I do not see this surrounded by ifndef
and I think that's just a simple portability mistake.
I am checking into how hard this is to patch, but I wanted to report it even before I did that in case I was doing something wrong.
The link to the cmake build example on the getting started page is as follows. - https://github.com/matt-42/lithium/tree/master/cmake_project_template
The link leads to 404. Should be -
https://github.com/matt-42/lithium/tree/master/cmake_project_template
# cat main.cc
#include <lithium_http_server.hh>
int main() {
http_api my_api;
my_api.get("/hello_world") =
[&](http_request& request, http_response& response) {
response.write("hello world");
};
http_serve(my_api, 8080);
}
# li run ./main.cc
Building in /tmp/lithium_build_d9f0e84949d824602fda52c4bc886391
X86 detected
MYSQL_INCLUDE_DIRS/usr/include/mariadb
/usr/lib/x86_64-linux-gnu/libmariadbclient.so
-- Configuring done
-- Generating done
-- Build files have been written to: /build
[ 0%] Built target symbols_generation
[ 50%] Building CXX object CMakeFiles/lithium_server.dir/source/main.cc.o
/source/main.cc: In function 'int main()':
/source/main.cc:4:3: error: 'http_api' was not declared in this scope; did you mean 'li::http_api'?
4 | http_api my_api;
| ^~~~~~~~
| li::http_api
In file included from /source/main.cc:1:
/usr/local/include/lithium_http_server.hh:6787:7: note: 'li::http_api' declared here
6787 | using http_api = api<http_request, http_response>;
| ^~~~~~~~
/source/main.cc:6:3: error: 'my_api' was not declared in this scope
6 | my_api.get("/hello_world") =
| ^~~~~~
/source/main.cc:7:7: error: 'http_request' has not been declared
7 | [&](http_request& request, http_response& response) {
| ^~~~~~~~~~~~
/source/main.cc:7:30: error: 'http_response' has not been declared
7 | [&](http_request& request, http_response& response) {
| ^~~~~~~~~~~~~
/source/main.cc: In lambda function:
/source/main.cc:8:14: error: request for member 'write' in 'response', which is of non-class type 'int'
8 | response.write("hello world");
| ^~~~~
/source/main.cc: In function 'int main()':
/source/main.cc:10:3: error: 'http_serve' was not declared in this scope; did you mean 'li::http_serve'?
10 | http_serve(my_api, 8080);
| ^~~~~~~~~~
| li::http_serve
In file included from /source/main.cc:1:
/usr/local/include/lithium_http_server.hh:6721:6: note: 'li::http_serve' declared here
6721 | auto http_serve(api<http_request, http_response> api, int port, O... opts) {
| ^~~~~~~~~~
make[2]: *** [CMakeFiles/lithium_server.dir/build.make:63: CMakeFiles/lithium_server.dir/source/main.cc.o] Error 1
/usr/local/include/li/sql/pgsql.hh:19:10: fatal error: libpq-fe.h: No such file or directory 19 | #include "libpq-fe.h" | ^~~~~~~~~~~~
Getting this error when compiling the pgsql database connection
Why is it pointing to current directory ?
Hello, I am trying to use lithium_http_server.hh for a HelloWorld project, but there are several includes that are Linux-specific like #include <arpa/inet.h> and cannot be found in MingW64, also this one for Windows is not present:
#if _WIN32
#include <wepoll.h>
#endif
Any suggestions? thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.