matt-42 / silicon Goto Github PK
View Code? Open in Web Editor NEWA high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead
Home Page: http://siliconframework.org
License: MIT License
A high performance, middleware oriented C++14 http web framework please use matt-42/lithium instead
Home Page: http://siliconframework.org
License: MIT License
Is there any way in which through the example ws_broadcast_server.cc
the server can trigger a broadcast to all clients, without the need of a client sending a message?
install.sh script uses NMake instead of MSYS Makefiles or MinGW Makefiles.
Hi,
I wanted to know if it's possible to add a custom HTTP header for response-header -- I mean, to the server (I'm using Ajax to get data from C++ API).
My only solution here, is to make Silicon running behind a reverse proxy (nginx, where I can put the custom header).
Thank you.
Hi Matthieu,
First thank you VERY much for this library, it is pretty exciting, and I'm hoping to use it a lot. To get it to work, I had to comment out (!) the call to MHD_http_unescape in mhd.hh (which effectively breaks unescaping of course). My 'homebrew' ships version 0.9.38 which does not appear to come with a user-visible unescape function.
I'm trying to figure out what the best thing to do is here, but maybe you have some ideas already.
Again, thanks for Silicon!
Hi.
The blog API example is pretty impressive, but it only shows one-to-many relationships. There is support for many to many relationships? Even a manual mode declaring a type for the relationship table?
I wold like to use Silicon as a RESTfull server to a frontend written in Riot.js as a pet project, but would need many to many relationships.
Hi
Can you please provide better documentation to compile the hello world example?
I tried the following and get errors.
I am using the following compiler:
$ g++ --version
g++-4.9.real (Ubuntu 4.9.2-0ubuntu1~14.04) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~/SILICON/bin/iodc hello_world.cpp hello_world_transformed.cpp
g++ -Wall -Wextra -std=c++1y -I/home/user/SILICON/include hello_world_transformed.cpp
In file included from /home/user/SILICON/include/silicon/mhd_serve.hh:9:0,
from hello_world_transformed.cpp:3:
/home/user/SILICON/include/silicon/service.hh: In member function ‘virtual void sl::handler<A, R, F, M, S>::operator()(M&, S&, sl::handler<A, R, F, M, S>::request_type&, sl::handler<A, R, F, M, S>::response_type&)’:
/home/user/SILICON/include/silicon/service.hh:51:50: warning: typedef ‘T’ locally defined but not used [-Wunused-local-typedefs]
typedef iod::callable_arguments_tuple_t T;
^
In file included from hello_world_transformed.cpp:3:0:
/home/user/SILICON/include/silicon/mhd_serve.hh: In function ‘int sl::mdh_keyvalue_iterator(void_, MHD_ValueKind, const char_, const char*)’:
/home/user/SILICON/include/silicon/mhd_serve.hh:67:3: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
hello_world_transformed.cpp: At global scope:
hello_world_transformed.cpp:10:6: error: ‘_hello’ is not a member of ‘s’
s::_hello= { return D(s::_message= "hello world.");}
^
hello_world_transformed.cpp: In lambda function:
hello_world_transformed.cpp:10:34: error: ‘_message’ is not a member of ‘s’
s::_hello= { return D(s::_message= "hello world.");}
Hey matt-42. silicon framework is one of the coolest thing I had ever seen and used. I saw today you commited a file streaming feature. Could you please provide an example of how to implement this? Thanks
I try to change the "Hello World" to "Hello FirstName LastName" like
_my_scope = D(_test2(_name=D(_first, _second), _age=int()) = [] (auto p) {
return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));
}),
with
#ifndef IOD_SYMBOL_first
#define IOD_SYMBOL_first iod_define_symbol(first)
#endif
#ifndef IOD_SYMBOL_second
#define IOD_SYMBOL_second
iod_define_symbol(second)
#endif
And I got such error message
error: ‘s::_name_t::variable_type<iod::sio<s::_first_t, s::_second_t> >::value_type’ has no member named ‘second’
return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));
error: ‘s::_name_t::variable_type<iod::sio<s::_first_t, s::_second_t> >::value_type’ has no member named ‘first’
return D(_message = "hello " + p.name.first + " " +p.name.second + " " + std::to_string(p.age));
What's the correct syntax to use nested structure?
I need to submit a jpeg image as form-data
. I've searched through examples but didn't find it. Please tell me if I missed it. Thanks
How to add a header Content-Type: application/json
to response? Maybe it would be more logically to insert it implicitly?
These files seems very helpful for reflection, could you please add some tests for them to show how to use the functions and also track they are not broken in later commits?
Hello, I'm getting these errors. Any idea what is wrong?
clang version 3.8.1 (tags/RELEASE_381/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
msvobod :: tmp/silicon-orig.git/examples ‹master› » make
-- Boost version: 1.61.0
-- Found the following Boost libraries:
-- system
-- thread
-- date_time
-- program_options
-- filesystem
-- chrono
-- atomic
-- Configuring done
-- Generating done
-- Build files have been written to: /home/milan/tmp/silicon-orig.git/examples
[ 12%] Building CXX object CMakeFiles/blog.dir/blog.cc.o
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:1:
/home/milan/tmp/silicon-orig.git/examples/../silicon/backends/mhd.hh:163:43: error: unknown type name 'json_string'
void decode_post_parameter_urlencoded(json_string*, T& res, const std::string& s) const
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/backends/mhd.hh:165:19: error: use of undeclared identifier 'json_string'
json_decode<json_string>(res, s);
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:19:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:41:46: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>,
iod::sio<> >, s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > >, s::_auto_increment_t>' requested here
using remove_auto_increment_t = decltype(remove_members_with_attribute(std::declval<T>(), _auto_increment));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:57:32: note: in instantiation of template type alias 'remove_auto_increment_t' requested here
typedef sql_orm_internals::remove_auto_increment_t<O> without_auto_inc_type;
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:25:22: note: in instantiation of template class 'sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >' requested here
typedef typename ORMI::object_type O; // O without primary keys for create procedure.
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:31:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:45:45: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>,
iod::sio<> >, s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > >, s::_primary_key_t>' requested here
using extract_primary_keys_t = decltype(extract_members_with_attribute(std::declval<T>(), _primary_key));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:60:32: note: in instantiation of template type alias 'extract_primary_keys_t' requested here
typedef sql_orm_internals::extract_primary_keys_t<O> PKS;
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:25:22: note: in instantiation of template class 'sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >' requested here
typedef typename ORMI::object_type O; // O without primary keys for create procedure.
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:19:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:43:48: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<int, s::_read_only_t>' requested here
using remove_read_only_fields_t = decltype(remove_members_with_attribute(std::declval<T>(), _read_only));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:28:32: note: in instantiation of template type alias 'remove_read_only_fields_t' requested here
typedef sql_orm_internals::remove_read_only_fields_t<O> update_type;
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:19:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:41:46: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<int, s::_auto_increment_t>' requested here
using remove_auto_increment_t = decltype(remove_members_with_attribute(std::declval<T>(), _auto_increment));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:29:32: note: in instantiation of template type alias 'remove_auto_increment_t' requested here
typedef sql_orm_internals::remove_auto_increment_t<update_type> insert_type;
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:1:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/backends/mhd.hh:11:
In file included from /usr/local/include/iod/json.hh:16:
In file included from /usr/local/include/iod/sio.hh:292:
/usr/local/include/iod/sio_utils.hh:66:64: error: no matching function for call to 'exp_to_variable'
sio<std::remove_const_t<std::remove_reference_t<decltype(exp_to_variable(args))>>...>
^~~~~~~~~~~~~~~
/home/milan/tmp/silicon-orig.git/examples/../silicon/http_route.hh:28:22: note: in instantiation of function template specialization 'iod::D<int>' requested here
typedef decltype(D(std::declval<P>()...)) sio_type;
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:70:24: note: in instantiation of function template specialization 'sl::post_parameters<int>' requested here
POST / _create * post_parameters(insert_type()) =
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
/usr/local/include/iod/sio_utils.hh:30:12: note: candidate template ignored: could not match 'variable<type-parameter-0-0>' against 'int'
const V& exp_to_variable(const variable<V>& v)
^
/usr/local/include/iod/sio_utils.hh:36:12: note: candidate template ignored: could not match 'symbol<type-parameter-0-0>' against 'int'
const S& exp_to_variable(const symbol<S>& s)
^
/usr/local/include/iod/sio_utils.hh:42:8: note: candidate template ignored: could not match 'function_call_exp<type-parameter-0-0, type-parameter-0-1...>' against 'int'
auto exp_to_variable(const function_call_exp<S, ARGS...>& e)
^
/usr/local/include/iod/sio_utils.hh:49:8: note: candidate template ignored: could not match 'assign_exp<type-parameter-0-0, type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<S, V>& e)
^
/usr/local/include/iod/sio_utils.hh:56:8: note: candidate template ignored: could not match 'assign_exp<function_call_exp<type-parameter-0-0, type-parameter-0-2...>,
type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<function_call_exp<S, ARGS...>, V>& e)
^
/usr/local/include/iod/sio_utils.hh:69:24: error: no matching function for call to 'exp_to_variable'
return result_type(exp_to_variable(args)...);
^~~~~~~~~~~~~~~
/usr/local/include/iod/sio_utils.hh:30:12: note: candidate template ignored: could not match 'variable<type-parameter-0-0>' against 'int'
const V& exp_to_variable(const variable<V>& v)
^
/usr/local/include/iod/sio_utils.hh:36:12: note: candidate template ignored: could not match 'symbol<type-parameter-0-0>' against 'int'
const S& exp_to_variable(const symbol<S>& s)
^
/usr/local/include/iod/sio_utils.hh:42:8: note: candidate template ignored: could not match 'function_call_exp<type-parameter-0-0, type-parameter-0-1...>' against 'int'
auto exp_to_variable(const function_call_exp<S, ARGS...>& e)
^
/usr/local/include/iod/sio_utils.hh:49:8: note: candidate template ignored: could not match 'assign_exp<type-parameter-0-0, type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<S, V>& e)
^
/usr/local/include/iod/sio_utils.hh:56:8: note: candidate template ignored: could not match 'assign_exp<function_call_exp<type-parameter-0-0, type-parameter-0-2...>,
type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<function_call_exp<S, ARGS...>, V>& e)
^
/usr/local/include/iod/sio_utils.hh:66:64: error: no matching function for call to 'exp_to_variable'
sio<std::remove_const_t<std::remove_reference_t<decltype(exp_to_variable(args))>>...>
^~~~~~~~~~~~~~~
/home/milan/tmp/silicon-orig.git/examples/../silicon/http_route.hh:29:36: note: in instantiation of function template specialization 'iod::D<int &>' requested here
return post_params_t<sio_type>(D(p...));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:70:24: note: in instantiation of function template specialization 'sl::post_parameters<int>' requested here
POST / _create * post_parameters(insert_type()) =
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:74:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_login_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >,
s::_password_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:76:22)>, iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:82:17)>,
iod::assign_exp<s::_write_access_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:86:21)> >' requested here
_user = sql_crud<user_orm>(
^
/usr/local/include/iod/sio_utils.hh:30:12: note: candidate template ignored: could not match 'variable<type-parameter-0-0>' against 'int'
const V& exp_to_variable(const variable<V>& v)
^
/usr/local/include/iod/sio_utils.hh:36:12: note: candidate template ignored: could not match 'symbol<type-parameter-0-0>' against 'int'
const S& exp_to_variable(const symbol<S>& s)
^
/usr/local/include/iod/sio_utils.hh:42:8: note: candidate template ignored: could not match 'function_call_exp<type-parameter-0-0, type-parameter-0-1...>' against 'int'
auto exp_to_variable(const function_call_exp<S, ARGS...>& e)
^
/usr/local/include/iod/sio_utils.hh:49:8: note: candidate template ignored: could not match 'assign_exp<type-parameter-0-0, type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<S, V>& e)
^
/usr/local/include/iod/sio_utils.hh:56:8: note: candidate template ignored: could not match 'assign_exp<function_call_exp<type-parameter-0-0, type-parameter-0-2...>,
type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<function_call_exp<S, ARGS...>, V>& e)
^
/usr/local/include/iod/sio_utils.hh:69:24: error: no matching function for call to 'exp_to_variable'
return result_type(exp_to_variable(args)...);
^~~~~~~~~~~~~~~
/usr/local/include/iod/sio_utils.hh:30:12: note: candidate template ignored: could not match 'variable<type-parameter-0-0>' against 'int'
const V& exp_to_variable(const variable<V>& v)
^
/usr/local/include/iod/sio_utils.hh:36:12: note: candidate template ignored: could not match 'symbol<type-parameter-0-0>' against 'int'
const S& exp_to_variable(const symbol<S>& s)
^
/usr/local/include/iod/sio_utils.hh:42:8: note: candidate template ignored: could not match 'function_call_exp<type-parameter-0-0, type-parameter-0-1...>' against 'int'
auto exp_to_variable(const function_call_exp<S, ARGS...>& e)
^
/usr/local/include/iod/sio_utils.hh:49:8: note: candidate template ignored: could not match 'assign_exp<type-parameter-0-0, type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<S, V>& e)
^
/usr/local/include/iod/sio_utils.hh:56:8: note: candidate template ignored: could not match 'assign_exp<function_call_exp<type-parameter-0-0, type-parameter-0-2...>,
type-parameter-0-1>' against 'int'
auto exp_to_variable(const assign_exp<function_call_exp<S, ARGS...>, V>& e)
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:19:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:41:46: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t>
>, s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > >,
s::_auto_increment_t>' requested here
using remove_auto_increment_t = decltype(remove_members_with_attribute(std::declval<T>(), _auto_increment));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:57:32: note: in instantiation of template type alias 'remove_auto_increment_t' requested here
typedef sql_orm_internals::remove_auto_increment_t<O> without_auto_inc_type;
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:25:22: note: in instantiation of template class 'sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >' requested here
typedef typename ORMI::object_type O; // O without primary keys for create procedure.
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:92:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >,
iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:94:17)>, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:98:22)>, iod::assign_exp<s::_write_access_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:102:21)> >' requested here
_post = sql_crud<post_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:31:14: error: use of undeclared identifier 'foreach2'
return foreach2(o) | [&] (auto& m)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:45:45: note: in instantiation of function template specialization 'sl::sql_orm_internals::(anonymous
class)::operator()<iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t>
>, s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > >,
s::_primary_key_t>' requested here
using extract_primary_keys_t = decltype(extract_members_with_attribute(std::declval<T>(), _primary_key));
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:60:32: note: in instantiation of template type alias 'extract_primary_keys_t' requested here
typedef sql_orm_internals::extract_primary_keys_t<O> PKS;
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:25:22: note: in instantiation of template class 'sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >' requested here
typedef typename ORMI::object_type O; // O without primary keys for create procedure.
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:92:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >,
iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:94:17)>, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:98:22)>, iod::assign_exp<s::_write_access_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:102:21)> >' requested here
_post = sql_crud<post_orm>(
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
In file included from /home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:5:
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:43:48: error: no matching function for call to object of type 'sl::sql_orm_internals::(lambda at
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:16:42)'
using remove_read_only_fields_t = decltype(remove_members_with_attribute(std::declval<T>(), _read_only));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:28:32: note: in instantiation of template type alias 'remove_read_only_fields_t' requested here
typedef sql_orm_internals::remove_read_only_fields_t<O> update_type;
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:92:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >,
iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:94:17)>, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:98:22)>, iod::assign_exp<s::_write_access_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:102:21)> >' requested here
_post = sql_crud<post_orm>(
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:16:42: note: candidate template ignored: substitution failure [with $0 = int, $1 = s::_read_only_t]
auto remove_members_with_attribute = [] (const auto& o, const auto& a)
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:41:46: error: no matching function for call to object of type 'sl::sql_orm_internals::(lambda at
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:16:42)'
using remove_auto_increment_t = decltype(remove_members_with_attribute(std::declval<T>(), _auto_increment));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:29:32: note: in instantiation of template type alias 'remove_auto_increment_t' requested here
typedef sql_orm_internals::remove_auto_increment_t<update_type> insert_type;
^
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:92:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >,
iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:94:17)>, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:98:22)>, iod::assign_exp<s::_write_access_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:102:21)> >' requested here
_post = sql_crud<post_orm>(
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/middlewares/sql_orm.hh:16:42: note: candidate template ignored: substitution failure
[with $0 = int, $1 = s::_auto_increment_t]
auto remove_members_with_attribute = [] (const auto& o, const auto& a)
^
In file included from /home/milan/tmp/silicon-orig.git/examples/blog.cc:4:
In file included from /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:2:
/home/milan/tmp/silicon-orig.git/examples/../silicon/sql_crud.hh:70:24: error: no matching function for call to 'post_parameters'
POST / _create * post_parameters(insert_type()) =
^~~~~~~~~~~~~~~
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:92:11: note: in instantiation of function template specialization 'sl::sql_crud<sl::sql_orm<sl::sqlite_connection,
iod::sio<s::_id_t::variable_type<int, iod::sio<s::_auto_increment_t, s::_primary_key_t> >, s::_user_id_t::variable_type<int, iod::sio<s::_read_only_t> >,
s::_title_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> >, s::_body_t::variable_type<std::__cxx11::basic_string<char>, iod::sio<> > > >,
iod::assign_exp<s::_validate_t, (lambda at /home/milan/tmp/silicon-orig.git/examples/blog_api.hh:94:17)>, iod::assign_exp<s::_before_create_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:98:22)>, iod::assign_exp<s::_write_access_t, (lambda at
/home/milan/tmp/silicon-orig.git/examples/blog_api.hh:102:21)> >' requested here
_post = sql_crud<post_orm>(
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/http_route.hh:27:8: note: candidate template ignored: substitution failure [with P = <int>]
auto post_parameters(P... p) {
^
/home/milan/tmp/silicon-orig.git/examples/../silicon/http_route.hh:33:8: note: candidate template ignored: could not match 'sio<type-parameter-0-0...>' against 'int'
auto post_parameters(sio<P...> o) {
^
15 errors generated.
make[2]: *** [CMakeFiles/blog.dir/build.make:63: CMakeFiles/blog.dir/blog.cc.o] Chyba 1
make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/blog.dir/all] Chyba 2
make: *** [Makefile:84: all] Chyba 2
A lots of errors like:
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/libgnutls.a(sha-x86-ssse3.o):(.data.rel.ro+0x18): undefined reference to `nettle_sha256_init'
I have nettle_dev and libnettle4 installed. What else are missing?
I can report basic functionality on Linux using g++ 5.1, on 4.9 the C++ 2014 support is too weak it appears. This is all fine but it would be great to document it somewhere, it might lead people to think this is a clang project only.
Also, on Ubuntu 14.04 too I encountered the MHD unescape missing function.
If a procedure tries to return a SIO object with fields that carry the value zero, they will appear as empty strings on the HTTP response body. For instance:
return D(_foo = 0);
Will be serialized to {"foo":}
.
Is this the intended behaviour?
Edit: it seems the error is in the iod library. Should I close this?
There are a number of things I'd like to do:
If a path is not defined
The intent is to serve an AngularJS app and it seems avoidable to run nginx etc when silicon should be capable of throwing some HTML/JS/CSS files back at a browser.
From reading the docs, I got the impression that using a middleware is the way to go but couldn't see how the path interception would happen, seems all middleware are created before a request and destroyed when it's completed but if a path doesn't match a middleware wouldn't be called right?
I want to drop in wangle as a backend, is there a ref of things to do, not to do.
On both 1 and 2, I've had a quick browse of the code for mhd and it seems whether it's possible depends on the functionality of the backend, https://github.com/matt-42/silicon/blob/master/silicon/backends/mhd.hh#L363 for example appears to just do a hand off to microhttpd, is that right or have I missed something?
I was to accept something like this post_parameters(_objects = std::vector<MyObject>())
. How to do this?
Hey,
when compiling this:
`
#include <silicon/api.hh>
#include <silicon/backends/mhd.hh>
#include "symbols.h"
using namespace sl; // Silicon namespace
using namespace s; // Symbols namespace
int main()
{
// Define the API:
auto hello_api = http_api(
// The hello world procedure.
GET / _hello = [] () { return D(_message = "Hello world."); },
POST / _login * post_parameters(_uname, _pwd) = [] (auto param) {
if (param.uname == "Albert" && param.pwd == "test") {
return D(_status = "success");
} else {
return D(_status = "failure");
}
}
);
// Serve hello_api via microhttpd using the json format:
sl::mhd_json_serve(hello_api, 12345);
return 0;
}
`
I get a compilation error.
`
13:02:52 **** Build of configuration Debug for project SiliconTest ****
make pre-build main-build
iod_generate_symbols ../main.cpp ../symbols.h
Building file: ../main.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
In file included from ../main.cpp:10:0:
/usr/include/silicon/backends/mhd.hh: In instantiation of ‘sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request*) const::<lambda(auto:91)> [with auto:91 = s::_uname_t::variable_type<std::__cxx11::basic_string >; P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]’:
/usr/include/iod/foreach.hh:133:29: required from ‘decltype(auto) iod::internal::sio_foreach(std::enable_if_t<(typename std::remove_reference<_To>::type:: _size != 0)>, F, T1&&, T&& ...) [with F = sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]::<lambda(auto:91)>; T1 = const iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >&; T = {}; std::enable_if_t<(typename std::remove_reference<_To>::type:: _size != 0)> = void]’
/usr/include/iod/foreach.hh:168:42: required from ‘decltype(auto) iod::internal::foreach_sio_caller::run(F, std::index_sequence<I ...>) [with F = sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request*) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]::<lambda(auto:91)>; long unsigned int ...I = {0ul}; T = std::tuple<const iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >&>; std::index_sequence<I ...> = std::integer_sequence<long unsigned int, 0ul>]’
/usr/include/iod/foreach.hh:174:76: required from ‘decltype(auto) iod::internal::foreach_sio_caller::operator|(F) [with F = sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request*) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]::<lambda(auto:91)>; T = std::tuple<const iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >&>]’
/usr/include/silicon/backends/mhd.hh:212:20: required from ‘void sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request*) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]’
/usr/include/silicon/backends/mhd.hh:254:54: required from ‘auto sl::mhd_json_service_utils::deserialize(sl::mhd_json_service_utils::request_type*, P, T&) const [with P = sl::procedure<sl::http_route<sl::http_post, std::tuple<s::_login_t>, iod::sio<>, iod::sio<>, iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > > >, iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >, iod::sio<s::_status_t::variable_type<const char*, iod::sio<> > >, sl::bind_procedure2(F, std::tuple<_Elements ...>) [with F = main()::<lambda(auto:92)>; U = {iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >}]::<lambda(iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >)> >; T = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; sl::mhd_json_service_utils::request_type = sl::mhd_request]’
/usr/include/silicon/service.hh:66:34: required from ‘void sl::ws_handler<P, M, S, ARGS>::operator()(M&, S&, ARGS& ...) [with P = sl::procedure<sl::http_route<sl::http_post, std::tuple<s::_login_t>, iod::sio<>, iod::sio<>, iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > > >, iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >, iod::sio<s::_status_t::variable_type<const char, iod::sio<> > >, sl::bind_procedure2(F, std::tuple<_Elements ...>) [with F = main()::<lambda(auto:92)>; U = {iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >}]::<lambda(iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >)> >; M = std::tuplesl::mhd_session_cookie; S = sl::mhd_json_service_utils; ARGS = {sl::mhd_request, sl::mhd_response*, MHD_Connection*}]’
../main.cpp:35:1: required from here
/usr/include/silicon/backends/mhd.hh:219:13: error: cannot call member function ‘void sl::mhd_json_service_utils::decode_post_parameter_urlencoded(T*, U&, const string&) const [with T = std::__cxx11::basic_string; U = std::__cxx11::basic_string; std::__cxx11::string = std::__cxx11::basic_string]’ without object
decode_post_parameter_urlencoded((std::decay_t<decltype(m.value())>*) 0,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/silicon/backends/mhd.hh:230:30: error: use of ‘auto s::_uname_t::variable_type<T, INFO>::attributes() const [with T = std::__cxx11::basic_string; INFO = iod::sio<>]’ before deduction of ‘auto’
if(!m.attributes().has(_optional))
In file included from /usr/include/iod/grammar.hh:6:0,
from /usr/include/iod/sio.hh:9,
from /usr/include/silicon/api.hh:4,
from ../main.cpp:9:
/usr/include/iod/foreach.hh:53:5: error: ‘void iod::internal::sio_foreach_impl(std::enable_if_t<std::is_same<void, Ret>::value>, std::index_sequence<TSize ...>, F, T&& ...) [with Ret = void; F = sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]::<lambda(auto:91)>; long unsigned int ...TSize = {0ul, 1ul}; long unsigned int ...Nargs = {}; T = {const iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >&}; std::enable_if_t<std::is_same<void, Ret>::value> = void; std::index_sequence<TSize ...> = std::integer_sequence<long unsigned int, 0ul, 1ul>]’, declared using local type ‘sl::mhd_json_service_utils::decode_post_parameters_urlencoded(O&, sl::mhd_request*) const [with P = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >; O = iod::sio<s::_uname_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> >, s::_pwd_t::variable_type<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, iod::sio<> > >]::<lambda(auto:91)>’, is used but never defined [-fpermissive]
sio_foreach_impl(std::enable_if_t<std::is_same<void, Ret>::value>*,
^~~~~~~~~~~~~~~~
subdir.mk:18: recipe for target 'main.o' failed
make: *** [main.o] Error 1
13:02:56 Build Finished (took 3s.805ms)
`
When changing the post request to a get request, everything works fine.
GET / _login * get_parameters(_uname, _pwd) = [] (auto param) {...}
POST / _product_in_stock * post_parameters(_product_id = int(),
_price = double()) = [] (auto p) {
cout << "price = " << p.price << endl;
}
Next implementing request:
URL = http://192.168.1.10/product_in_stock
Headers = Content-Type:application/json
Method = POST
Body:
{
"product_id":1,
"price":1.5
}
Exception is thrown:
libc++abi.dylib: terminating with uncaught exception of type boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorboost::bad_lexical_cast >: bad lexical cast: source type value could not be interpreted as target
Hi, I just wanted to install silicon but I got the following error:
CMake Error at /usr/local/Cellar/cmake/3.1.0/share/cmake/Modules/CMakePackageConfigHelpers.cmake:254 (file):
file RELATIVE_PATH must be passed a full path to the file:
Call Stack (most recent call first):
CMakeLists.txt:17 (configure_package_config_file)
The log file CMakeOutput.log does not seem to include useful information.
OS:
OS X Yosemite 10.10.1
clang:
Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
cmake:
cmake version 3.1.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
Hello. Thanks for taking the time to write this and make it public. I came in via #42 but can see you use a unit testing framework.
I've been trying to generate coverage, both by forking your repo and running your travis.yml there are errors. I wasn't sure if you knew about them, including but not limited to commands for executable files that are not installed, passing a token that can just be set via travis settings.
I'm currently trying to fix these problems, but it seems C++ coverage is harder to generate than the same in Java, C# or scripting language.
Silicon is a great work and bravo to the creator and contributors.
I wish to know
Thanks
How to set response status code? I have tried status field in mhd_response* res, but seems to be it gets overwritten by the framework to 200.
Trying to compile helloworld sample in OpenSUSE, with command:
clang++ -std=c++14 -I /home/eduardo/C/SiliconWebAPI/include -I /home/eduardo/C/microhttpd/include hello_world.cc -lmicrohttpd -o hello_world
I got these error:
In file included from /home/eduardo/C/SiliconWebAPI/include/silicon/backends/mhd.hh:27:
/home/eduardo/C/SiliconWebAPI/include/silicon/backends/urldecode.hh:35:22: error: use of undeclared identifier 'MHD_http_unescape'
content.resize(MHD_http_unescape(&content[0]));
^
In file included from hello_world.cc:2:
/home/eduardo/C/SiliconWebAPI/include/silicon/backends/mhd.hh:486:15: error: use of undeclared identifier
'MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY'
flags = MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY;
^
/home/eduardo/C/SiliconWebAPI/include/silicon/backends/mhd.hh:540:36: error: use of undeclared identifier 'MHD_FEATURE_SSL'
if (MHD_is_feature_supported(MHD_FEATURE_SSL) == MHD_NO)
Some idea?
During compilation, I get the following error:
/usr/local/include/silicon/backends/websocketpp.hh:7:46: fatal error: websocketpp/config/asio_no_tls.hpp: No such file or directory compilation terminated.
I cannot find such file anywhere in the repo. Am I supposed to install websocketpp
separately or something? It doesn't appear in the installation page.
For instance, how should I compile the example ws_broadcast_server.cc
?
after the install , should I see also silicon lib file in the bin folder ?
Could you please consider adding lwan (https://github.com/lpereira/lwan) as a backend? lwan has some good performance optimization e.g. cpu branch prediction, json encoder/decoder, and hence faster than MHD in several benchmark tests.
I'm plaing with rest.cc from tests and it seems to accept application/x-www-form-urlencoded only.
How to accept application/json as input?
I tried to compile Silicon on Fedora 23 and I got this return:
[leandro@serpro-01532821 silicon]$ ./install.sh ~/local/silicon
-- Configuring done
-- Generating done
-- Build files have been written to: /home/leandro/local/src/silicon/silicon_build
Install the project...
-- Install configuration: ""
-- Up-to-date: /home/leandro/local/silicon/include/silicon
-- Up-to-date: /home/leandro/local/silicon/include/silicon/procedure_desc.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/sql_crud.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/hash.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middleware_factories.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/http_route.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/service.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/utils.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/optional.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/dynamic_routing_table.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/get_parameters.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/mysql_connection.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sql_orm.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sqlite_orm.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/hashmap_session.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/mysql_orm.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/mysql_types.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sqlite_connection.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/tracking_cookie.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sqlite_types.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/mysql_session.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sql_session.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares/sqlite_session.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/libcurl_client.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/javascript_client.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/templates
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/templates/javascript_websocket.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/templates/javascript.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/null.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/wspp_connection.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/mimosa.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/websocketpp.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/mhd.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/h2o.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/ws_api.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/websocketpp_remote_client.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/ws_route.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/cppnet.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends/lwan.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/response.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/api_to_sio.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/di_factories.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/api_description.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/remote_api.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/error.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/file.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/api.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/blob.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/base_64.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/sql_rest.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon/symbols.hh
-- Up-to-date: /home/leandro/local/silicon/include/silicon
-- Up-to-date: /home/leandro/local/silicon/include/silicon/middlewares
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients
-- Up-to-date: /home/leandro/local/silicon/include/silicon/clients/templates
-- Up-to-date: /home/leandro/local/silicon/include/silicon/backends
mkdir: cannot create directory ‘externals’: File exists
fatal: destination path 'iod' already exists and is not an empty directory.
-- Boost version: 1.58.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/leandro/local/src/silicon/silicon_build/externals/iod/silicon_build
[ 13%] Building CXX object tests/CMakeFiles/bind_method.dir/bind_method.cc.o
[ 13%] Built target iod_generate_symbols
[ 22%] Built target apply
[ 31%] Built target callable_traits
[ 50%] Built target deep_merge
[ 50%] Built target core
[ 59%] Built target di
[ 77%] Built target foreach
[ 77%] Built target readme
[ 86%] Built target json
[ 95%] Built target tuple
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/bind_method-17bdc5.cpp
clang: note: diagnostic msg: /tmp/bind_method-17bdc5.sh
clang: note: diagnostic msg:
********************
tests/CMakeFiles/bind_method.dir/build.make:62: recipe for target 'tests/CMakeFiles/bind_method.dir/bind_method.cc.o' failed
make[2]: *** [tests/CMakeFiles/bind_method.dir/bind_method.cc.o] Error 254
CMakeFiles/Makefile2:195: recipe for target 'tests/CMakeFiles/bind_method.dir/all' failed
make[1]: *** [tests/CMakeFiles/bind_method.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
Cannot install /home/leandro/local/silicon.
I am running:
Fedora 23
clang 3.7.0
libboost 1.58
libmicrohttpd 0.9.39
silicon
is really an awesome framework, thanks for the great work.
When writting APIs using silicon, I need to call other RESTful APIs what are served as http service.
I wrote dummy sl::http_api
, and use libcurl_json_client
to make requests.
However the libcurl_json_client
seemed designed for testing. Found no way to specify something like a auth header nor ways to retrieve headers from the response.
It will be really convenient if I can write some code like this:
auto client = https("127.0.0.1") | port(8080) | opt(_insecure_skip_verify = true) | prefix(_api / _v1);
auto create_pod = client.post(_namespaces / _namespace[std::string()] / pods) | body<yaml_encoder>(
D(_name = "a_name", _image = optional(std::string("alpine")))) | headers("Authorization", _auth[std::string()])
| headers("a_header_key", "a_header_value") | content_type("application/x-yaml"); // content type could be set by the encoder.
auto response = create_pod(_namespace = "kube-system", _auth = "Basic c2lsaWNvbjphd2Vzb21lCg==");
auto a_sturct = create_pod<json_decoder>(_namespace = "kube-system", _auth = "Basic c2lsaWNvbjphd2Vzb21lCg==", _image = "busybox"); // decoder could access the response body and headers.
istream& raw_body = create_pod<raw>(_namespace = "kube-system", _auth = "Basic c2lsaWNvbjphd2Vzb21lCg==");
std::unordered_map<std::string, std::string> some_headers = {
{"Authorization", "Basic c2lsaWNvbjphd2Vzb21lCg=="},
{"key", "value"}
};
auto response = request<post>("http://127.0.0.1:8080/api/v1/namespaces/kube-system/pods", _body = D(_name = "a_name"), _headers = some_headers);
int status = response.status_code;
istream& raw_body = response.body<raw>();
auto struct_body = response.body<some_decoder>();
std::unordered_map<std::string, std::string> response_headers = response.headers();
auto struct_header = response.headers<some_parser>();
auto ws_client = http("127.0.0.1");
auto events = ws_client.watch(_apis / _batch / _v1 / _watch / _namespaces / _namespace[std::string()] / jobs / _name[std::string()]);
events = events | on_message([] (some_struct& message) {
// do some thing.
});
events = events | _on_close = [] (some_struct& message) {
// do some thing.
};
auto sync = events(_namespace = "kube-system", _name = "busybox");
sync.wait();
I write some c++, but lack of experience and advanced skills to write such elegant code like silicon. But I can still try to give a hand.
I want to use a secured connection in case if someone listens to internet traffic to keep access token safe. How to perform this thing with silicone framework?
I'd like to be able to read the headers from a request and also be able to add/modify the response headers - how could that be accomplished? middleware?
Hi Matt,
how does one go about writing custom paths such as /hello/John
and getting John as a param ?
Thank You
Here is the console output:
09:55:21 **** Incremental Build of configuration Debug for project SiliconTest ****
make pre-build main-build
iod_generate_symbols ../main.cpp ../symbols.h
Building file: ../main.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh: In instantiation of ‘auto sl::make_ws_route(const E&) [with E = iod::function_call_exp<s::_message_t, s::_text_t>]’:
/usr/include/silicon/remote_api.hh:40:41: required from ‘auto sl::make_ws_remote_api(P ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’
/usr/include/silicon/backends/websocketpp_remote_client.hh:106:34: required from ‘auto sl::make_wspp_remote_client(const P& ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’
../main.cpp:100:59: required from here
/usr/include/silicon/backends/ws_api.hh:144:21: error: no matching function for call to ‘route_cat(sl::ws_route<>, const iod::function_call_exp<s::_message_t, s::_text_t>&)’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:12:0,
from ../main.cpp:39:
/usr/include/silicon/http_route.hh:284:8: note: candidate: template<class ... R1, class ... R2> auto sl::route_cat(const sl::http_route<R1 ...>&, const sl::http_route<R2 ...>&)
auto route_cat(const http_route<R1...>& r1,
^~~~~~~~~
/usr/include/silicon/http_route.hh:284:8: note: template argument deduction/substitution failed:
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘sl::ws_route<>’ is not derived from ‘const sl::http_route<R1 ...>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:12:0,
from ../main.cpp:39:
/usr/include/silicon/http_route.hh:291:8: note: candidate: template<class ... R1, class R2> auto sl::route_cat(const sl::http_route<R1 ...>&, const R2&)
auto route_cat(const http_route<R1...>& r1,
^~~~~~~~~
/usr/include/silicon/http_route.hh:291:8: note: template argument deduction/substitution failed:
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘sl::ws_route<>’ is not derived from ‘const sl::http_route<R1 ...>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:13:0,
from ../main.cpp:39:
/usr/include/silicon/rmq_route.hh:164:7: note: candidate: template<class ... R1, class ... R2> auto sl::route_cat(const sl::rmq::route<R1 ...>&, const sl::rmq::route<R2 ...>&)
auto route_cat(rmq::route<R1...> const & r1,
^~~~~~~~~
/usr/include/silicon/rmq_route.hh:164:7: note: template argument deduction/substitution failed:
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘sl::ws_route<>’ is not derived from ‘const sl::rmq::route<R1 ...>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:13:0,
from ../main.cpp:39:
/usr/include/silicon/rmq_route.hh:171:7: note: candidate: template<class ... R1, class R2> auto sl::route_cat(const sl::rmq::route<R1 ...>&, const R2&)
auto route_cat(rmq::route<R1...> const & r1,
^~~~~~~~~
/usr/include/silicon/rmq_route.hh:171:7: note: template argument deduction/substitution failed:
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘sl::ws_route<>’ is not derived from ‘const sl::rmq::route<R1 ...>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:118:8: note: candidate: template<class S, class P, class SS> auto sl::route_cat(sl::ws_route<S, P>, const iod::symbol&)
auto route_cat(ws_route<S, P> r, const iod::symbol& s)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:118:8: note: template argument deduction/substitution failed:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘const iod::function_call_exp<s::_message_t, s::_text_t>’ is not derived from ‘const iod::symbol’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:124:8: note: candidate: template<class S, class P, class T> auto sl::route_cat(sl::ws_route<S, P>, const sl::params_t&)
auto route_cat(ws_route<S, P> r, const params_t& s)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:124:8: note: template argument deduction/substitution failed:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘const iod::function_call_exp<s::_message_t, s::_text_t>’ is not derived from ‘const sl::params_t’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:130:8: note: candidate: template<class S, class P, class L, class R> auto sl::route_cat(sl::ws_route<S, P>, const iod::div_exp<L, R>&)
auto route_cat(ws_route<S, P> r, const iod::div_exp<L, R>& e)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:130:8: note: template argument deduction/substitution failed:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘const iod::function_call_exp<s::_message_t, s::_text_t>’ is not derived from ‘const iod::div_exp<L, R>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:136:8: note: candidate: template<class S, class P, class L, class R> auto sl::route_cat(sl::ws_route<S, P>, const iod::mult_exp<L, R>&)
auto route_cat(ws_route<S, P> r, const iod::mult_exp<L, R>& e)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:136:8: note: template argument deduction/substitution failed:
/usr/include/silicon/backends/ws_api.hh:144:21: note: ‘const iod::function_call_exp<s::_message_t, s::_text_t>’ is not derived from ‘const iod::mult_exp<L, R>’
return route_cat(ws_route<>(), e);
~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from ../main.cpp:40:0:
/usr/include/silicon/remote_api.hh: In instantiation of ‘auto sl::make_ws_remote_api(P ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’:
/usr/include/silicon/backends/websocketpp_remote_client.hh:106:34: required from ‘auto sl::make_wspp_remote_client(const P& ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’
../main.cpp:100:59: required from here
/usr/include/silicon/remote_api.hh:40:27: error: invalid use of void expression
return std::make_tuple(make_ws_route(procs)...);
~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/silicon/backends/websocketpp.hh:13:0,
from ../main.cpp:41:
/usr/include/silicon/backends/websocketpp_remote_client.hh: In instantiation of ‘auto sl::make_wspp_remote_client(const P& ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’:
../main.cpp:100:59: required from here
/usr/include/silicon/backends/websocketpp_remote_client.hh:106:48: error: ‘void api’ has incomplete type
auto api = make_ws_remote_api(procedures...);
^
/usr/include/silicon/backends/websocketpp_remote_client.hh:108:36: error: use of ‘auto iod::assignable::operator=(L&&) const [with L = std::shared_ptrsl::wspp_remote_client_ctx&; E = s::_silicon_ctx_t]’ before deduction of ‘auto’
auto accessor = D(_silicon_ctx = c);
~~~~~~~~~~~~~^~~
/usr/include/silicon/backends/websocketpp_remote_client.hh: In instantiation of ‘struct sl::make_wspp_remote_client(const P& ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]::<lambda(struct sl::wspp_connection)>’:
/usr/include/silicon/backends/websocketpp_remote_client.hh:116:5: required from ‘auto sl::make_wspp_remote_client(const P& ...) [with P = {iod::function_call_exp<s::_message_t, s::_text_t>}]’
../main.cpp:100:59: required from here
/usr/include/silicon/backends/websocketpp_remote_client.hh:111:13: error: using invalid field ‘sl::make_wspp_remote_client(const P& ...)::<lambda(sl::wspp_connection)>::’
return [rc] (wspp_connection c) {
^~
../main.cpp: In function ‘int main(int, char**)’:
../main.cpp:100:59: error: ‘void rclient’ has incomplete type
auto rclient = make_wspp_remote_client( _message(_text) );
^
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh: In instantiation of ‘sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)>::<lambda(auto:67)> [with auto:67 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::message_t>, main(int, char**)::<lambda(auto:136)> >}]’:
/usr/include/iod/utils.hh:24:19: required from ‘decltype(auto) iod::static_if::operator()(F, G, A&& ...) [with F = sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)> [with auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:66)>; G = sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)> [with auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:67)>; A = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >&}]’
/usr/include/iod/utils.hh:31:27: required from ‘decltype(auto) iod::static_if(F, G, A&& ...) [with bool C = false; F = sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)> [with auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:66)>; G = sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)> [with auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:67)>; A = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >&}]’
/usr/include/silicon/api.hh:210:59: required from ‘sl::parse_api(std::tuple<_Args2 ...>, R)::<lambda(auto:65)> [with auto:65 = iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >; R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]’
/usr/include/iod/foreach.hh:116:29: required from ‘decltype(auto) iod::internal::tuple_foreach(F, T1&&, T&& ...) [with F = sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>; T1 = std::tuple<iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> > >&; T = {}]’
/usr/include/iod/foreach.hh:146:44: required from ‘decltype(auto) iod::internal::foreach_tuple_caller::run(F, std::index_sequence<I ...>) [with F = sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>; long unsigned int ...I = {0ul}; T = std::tuple<std::tuple<iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> > >&>; std::index_sequence<I ...> = std::integer_sequence<long unsigned int, 0ul>]’
/usr/include/iod/foreach.hh:152:76: required from ‘decltype(auto) iod::internal::foreach_tuple_caller::operator|(F) [with F = sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>; T = std::tuple<std::tuple<iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> > >&>]’
/usr/include/silicon/api.hh:208:25: required from ‘auto sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]’
/usr/include/silicon/backends/ws_api.hh:150:21: required from ‘auto sl::ws_api(P ...) [with P = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]’
../main.cpp:110:5: required from here
/usr/include/silicon/api.hh:216:29: error: no matching function for call to ‘route_cat(sl::ws_route<>&, iod::function_call_exp<s::_broadcast_t, s::_message_t>&)’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:12:0,
from ../main.cpp:39:
/usr/include/silicon/http_route.hh:284:8: note: candidate: template<class ... R1, class ... R2> auto sl::route_cat(const sl::http_route<R1 ...>&, const sl::http_route<R2 ...>&)
auto route_cat(const http_route<R1...>& r1,
^~~~~~~~~
/usr/include/silicon/http_route.hh:284:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘sl::ws_route<>’ is not derived from ‘const sl::http_route<R1 ...>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:12:0,
from ../main.cpp:39:
/usr/include/silicon/http_route.hh:291:8: note: candidate: template<class ... R1, class R2> auto sl::route_cat(const sl::http_route<R1 ...>&, const R2&)
auto route_cat(const http_route<R1...>& r1,
^~~~~~~~~
/usr/include/silicon/http_route.hh:291:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘sl::ws_route<>’ is not derived from ‘const sl::http_route<R1 ...>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:13:0,
from ../main.cpp:39:
/usr/include/silicon/rmq_route.hh:164:7: note: candidate: template<class ... R1, class ... R2> auto sl::route_cat(const sl::rmq::route<R1 ...>&, const sl::rmq::route<R2 ...>&)
auto route_cat(rmq::route<R1...> const & r1,
^~~~~~~~~
/usr/include/silicon/rmq_route.hh:164:7: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘sl::ws_route<>’ is not derived from ‘const sl::rmq::route<R1 ...>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/api.hh:13:0,
from ../main.cpp:39:
/usr/include/silicon/rmq_route.hh:171:7: note: candidate: template<class ... R1, class R2> auto sl::route_cat(const sl::rmq::route<R1 ...>&, const R2&)
auto route_cat(rmq::route<R1...> const & r1,
^~~~~~~~~
/usr/include/silicon/rmq_route.hh:171:7: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘sl::ws_route<>’ is not derived from ‘const sl::rmq::route<R1 ...>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:136:8: note: candidate: template<class S, class P, class L, class R> auto sl::route_cat(sl::ws_route<S, P>, const iod::mult_exp<L, R>&)
auto route_cat(ws_route<S, P> r, const iod::mult_exp<L, R>& e)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:136:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘iod::function_call_exp<s::_broadcast_t, s::_message_t>’ is not derived from ‘const iod::mult_exp<L, R>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:130:8: note: candidate: template<class S, class P, class L, class R> auto sl::route_cat(sl::ws_route<S, P>, const iod::div_exp<L, R>&)
auto route_cat(ws_route<S, P> r, const iod::div_exp<L, R>& e)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:130:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘iod::function_call_exp<s::_broadcast_t, s::_message_t>’ is not derived from ‘const iod::div_exp<L, R>’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:124:8: note: candidate: template<class S, class P, class T> auto sl::route_cat(sl::ws_route<S, P>, const sl::params_t&)
auto route_cat(ws_route<S, P> r, const params_t& s)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:124:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘iod::function_call_exp<s::_broadcast_t, s::_message_t>’ is not derived from ‘const sl::params_t’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/silicon/remote_api.hh:4:0,
from ../main.cpp:40:
/usr/include/silicon/backends/ws_api.hh:118:8: note: candidate: template<class S, class P, class SS> auto sl::route_cat(sl::ws_route<S, P>, const iod::symbol&)
auto route_cat(ws_route<S, P> r, const iod::symbol& s)
^~~~~~~~~
/usr/include/silicon/backends/ws_api.hh:118:8: note: template argument deduction/substitution failed:
In file included from ../main.cpp:39:0:
/usr/include/silicon/api.hh:216:29: note: ‘iod::function_call_exp<s::_broadcast_t, s::_message_t>’ is not derived from ‘const iod::symbol’
auto r = route_cat(route, m.left);
~~~~~~~~~^~~~~~~~~~~~~~~
../main.cpp:110:5: error: ‘void server_api’ has incomplete type
);
^
In file included from /usr/include/iod/grammar.hh:6:0,
from /usr/include/iod/sio.hh:9,
from /usr/include/silicon/api.hh:4,
from ../main.cpp:39:
/usr/include/iod/foreach.hh: At global scope:
/usr/include/iod/foreach.hh:27:5: error: ‘void iod::internal::tuple_foreach_impl(std::enable_if_t<std::is_same<void, Ret>::value>, std::index_sequence<TSize ...>, F, T&& ...) [with Ret = void; F = sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>; long unsigned int ...TSize = {0ul}; long unsigned int ...Nargs = {}; T = {std::tuple<iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> > >&}; std::enable_if_t<std::is_same<void, Ret>::value> = void; std::index_sequence<TSize ...> = std::integer_sequence<long unsigned int, 0ul>]’, declared using local type ‘sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>’, is used but never defined [-fpermissive]
tuple_foreach_impl(std::enable_if_t<std::is_same<void, Ret>::value>,
^~~~~~~~~~~~~~~~~~
/usr/include/iod/foreach.hh:27:5: warning: ‘void iod::internal::tuple_foreach_impl(std::enable_if_t<std::is_same<void, Ret>::value>*, std::index_sequence<TSize ...>, F, T&& ...) [with Ret = void; F = sl::parse_api(std::tuple<_Args2 ...>, R) [with R = sl::ws_route<>; T = {iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> >}]::<lambda(auto:65)>; long unsigned int ...TSize = {0ul}; long unsigned int ...Nargs = {}; T = {std::tuple<iod::assign_exp<iod::function_call_exp<s::_broadcast_t, s::_message_t>, main(int, char**)::<lambda(auto:136)> > >&}]’ used but never defined
make: *** [main.o] Error 1
subdir.mk:18: recipe for target 'main.o' failed
09:55:28 Build Finished (took 6s.682ms)
I did fix the bug that a set was not regonized by adding the required include.
I was wondering; is there a future plan to use Silicon with a previously established unit testing framework, like Catch or Google Test? I've found that it's extremely helpful to be able to write unit tests in the course of development, and I would figure that having the same power would be helpful.
Don't get me wrong with all these tickets, they are because I like what I am seeing. I might also PR this up. But, only binding to a 'port' is going to cause immediate problems for my use of Silicon. I checked out the microhttpd way to do this and it is quite nice, but it does not immediately fit on mhd_json_serve, unless we accept an IP address as a string in which case it is rather easy.
Thoughts?
`#include
using namespace sl; // Silicon namespace
using namespace s; // Symbols namespace
int main()
{
typedef decltype(D(_name = std::string(), _age = int(), _city = std::string())) User;
User u("John", 23, "NYC");
std::vector<User> ul;
ul.push_back(u);
std::cout << "-----type_string(User)-----" <<std::endl;
std::cout << type_string( &u ) <<std::endl;
std::cout << "-----type_string(std::vector<user>)-----" <<std::endl;
std::cout << type_string( &ul ) <<std::endl;
return 0;
}`
out put :
-----type_string(User)-----
{name: string, age: int, city: string}
-----type_string(std::vector<user>)-----
vector of void
Is there some way to make "type_string(std::vector*)" to output "vector of {name: string, age: int, city: string}"
When I first ran the install.sh for the project it failed because in the file
silicon_build/externals/iod/tools/iod_generate_symbols.cc
it is missing the sstream library and because you use a stringstream object it complained and didn't finish the install. Once I added that library in the file everything installed successfully. So if people have trouble with installing the project, this could be the problem their having.
I'd like to write a code like this:
PUT / _region * post_parameters(_id = int(),
_x = int(),
_y = int(),
_width = int(),
_height = int(),
_comment = std::string(),
_type = std::string(),
_near = std::vector<int>()) = [] (auto p) {
return regionController.put(p.id,
p.x,
p.y,
p.width,
p.height,
p.comment,
p.type,
p.near);
}
but I receive a static_assert with
"Target type is neither std::istream`able nor std::wistream`able"
text
I'd like to accept JSON post data instead of form-data. ie.
{"email":"[email protected]","password":"1234567"}
Instead of:
[email protected]&password=1234567
from https://github.com/matt-42/iod, it seems we can use named optional function arguments to do it, but could you please give a simple example on the right syntax?
with so large error messge that I don't event to post it here...
log.txt
How does one add headers to lwan ? Thanks
I saw
find_package( Iod )
in tests/CMakeLists.txt
But cannot find FindIod.cmake anywhere :)
https://www.techempower.com/benchmarks/
This is the most comprehensive set that I know of.
I'm not associated in anyway.
Hi Matthieu ,
I am getting an error with Lwan Backend, possibly lwan has updated breaking changes.
This is the error:
In file included from /usr/local/include/lwan/lwan.h:35:0,
from /usr/local/include/silicon/backends/lwan.hh:8,
from main.cpp:18:
/usr/local/include/lwan/lwan.h: In function ‘lwan_key_value* lwan_key_value_array_append(lwan_key_value_array*)’:
/usr/local/include/lwan/lwan.h:239:1: error: invalid conversion from ‘void*’ to ‘lwan_key_value*’ [-fpermissive]
DEFINE_ARRAY_TYPE(lwan_key_value_array, struct lwan_key_value)
^
In file included from main.cpp:18:0:
/usr/local/include/silicon/backends/lwan.hh: At global scope:
/usr/local/include/silicon/backends/lwan.hh:27:5: error: ‘lwan_request_t’ does not name a type
lwan_request_t* lwan_req;
^
/usr/local/include/silicon/backends/lwan.hh:32:33: error: expected ‘)’ before ‘’ token
lwan_response(lwan_request_t _lwan_req, lwan_response_t* _lwan_resp)
^
main.cpp:297:1: error: expected ‘}’ at end of input
}
^
main.cpp:297:1: error: expected unqualified-id at end of input
main.cpp:297:1: error: expected ‘}’ at end of input
Thanks
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.