Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Rafael Bugajewski
    @rbugajewski
    thylacinelol
    @thylacinelol
    Hi
    Is it possible to automatically route paths to static html files?
    For example, make http://localhost:3000/hello serve http://localhost:3000/hello.html if the html file exists?
    P.R.
    @prothegee

    @thylacinelol
    if you configure document_root directory and add *.html files, public can access it,
    even if it's located on document_root/docs/how-to-x.html
    this is also equilevant as domain.tld[:port-if-any]/docs/how-to-y.html

    open this https://drogon.org/images/drogon-concise-white.png and look https://github.com/drogonframework/drogon-website/tree/master/content/images

    thylacinelol
    @thylacinelol
    @prothegee yep, serving files works fine - I can access the page via domain.tld[:port]/hello.html, however, I want to remove the .html, so that you can access the filehello.html via domain.tld[:port]/hello.
    P.R.
    @prothegee

    @thylacinelol

    something like this doable with c++20


    Home.h

    namespace MyProject
    {
    namespace controllers
    {
    
    
    class Home
        :   public drogon::HttpController<Home>
    {
    
    public:
        METHOD_LIST_BEGIN
        ADD_METHOD_TO(Home::HomePage, "/", drogon::Get);
        ADD_METHOD_TO(Home::HelloPage, "/hello", drogon::Get);
    
    
        METHOD_LIST_END
        void HomePage(const drogon::HttpRequestPtr &req,
                        std::function<void(const drogon::HttpResponsePtr&)>&&callback);
    
        drogon::AsyncTask HelloPage(const drogon::HttpRequestPtr req,
                        std::function<void(const drogon::HttpResponsePtr&)>callback);
    
    }; // class Home
    
    
    } // namespace controllers
    } // namespace MyProject

    Home.cc

    #include "Home.h"
    
    
    using namespace backendV1::controllers;
    
    
    void Home::HomePage(const drogon::HttpRequestPtr &req,
                        std::function<void(const drogon::HttpResponsePtr&)>&&callback)
    {
        // ... some logic
    }
    
    
    drogon::AsyncTask Home::HelloPage(const drogon::HttpRequestPtr req,
                        std::function<void(const drogon::HttpResponsePtr&)>callback)
    {
        auto client = drogon::HttpClient::newHttpClient("http://www.localhost.com:8001");
        auto request = drogon::HttpRequest::newHttpRequest();
        request->setMethod(drogon::Get);
        request->setPath("/hello.html");
    
        auto foo = co_await client->sendRequestCoro(request);
        auto bar = foo->getBody();
    
        std::string baz{bar};
    
        resp = drogon::HttpResponse::newHttpResponse();
        resp->setBody(baz);
    
        callback(resp);
    }
    image.png
    I didn't know that was doable till now, LOL
    P.R.
    @prothegee
    Otherwise I didn't know yet for another solution
    P.R.
    @prothegee
    image.png
    thylacinelol
    @thylacinelol
    woah nice, thanks!
    P.R.
    @prothegee
    image.png
    Hi, is anyone know how to change cookie domain name?
    aliakbarrashidi
    @aliakbarrashidi:matrix.org
    [m]
    Hi, how can I stop accepting more than particular amount of request from one origin ( based on IP or whatever else) to prevent scrapping my endpoints?
    2 replies
    headofdeveloper
    @headofdeveloper
    hi @an-tao, we have an issue related to LOG_DEBUG macro. When we integrate our system with an external logging system which uses syslog, as syslog has same macro it is overriding. Is it possbile to use some prefix before those macros. LOG_DEBUG, LOG_ERROR etc is very common and mostly logging libraries uses them.
    An Tao
    @an-tao

    Hi, is anyone know how to change cookie domain name?

    I don't think drogon sends domain name in session cookie, please confirm it via packet capturing tools.

    1 reply

    hi @an-tao, we have an issue related to LOG_DEBUG macro. When we integrate our system with an external logging system which uses syslog, as syslog has same macro it is overriding. Is it possbile to use some prefix before those macros. LOG_DEBUG, LOG_ERROR etc is very common and mostly logging libraries uses them.

    The solution I can think of is to compile your app with dragon source code, then resolve the conflict by string replacing

    Ichiro
    @HadesD

    how can I make two request not blocking each-others?
    Currently my problem:

    • request1: run with block HttpClient Request inside
    • request2: has to wait request1 completed (callback)

    How can I continue request2 without wait request1 to completed?

    Ichiro
    @HadesD
    ok, I use coro + CurrentThreadEventLoop then it solved problem
    I think you should add document to coroutines https://drogon.docsforge.com/master/coroutines/#enabling-coroutines
    add example of HttpClient also
    @an-tao
    Ichiro
    @HadesD
    Re-tested
    I 've found this, if I build drogon with ./build.sh -t , it not problem with deadlock when use coro.httpclient on controller, without -t flag, it will be trouble with deadlock
    house-mouse
    @house-mouse
    Hello Drogon folks! Thanks for your awesome work on this project! I am wondering if it's possible to have wildcards in websocket urls? Can something like WS_PATH_ADD("/session/{1}") be used and then the path parameter picked up in some way similar to how METHOD_ADD works with something like METHOD_ADD(Book::getInfo,"/{1}",Get); ? It looks like METHOD_ADD doesn't have any method like Ws akin to Get or Post to be able to catch things before websocket negotiation fully turns the request into a websocket connection, so I'm not sure where or how I might be able to grab the url early in the negotiation? Thanks for any thoughts!
    An Tao
    @an-tao
    Currently you can't do that. WebsocketController is just like HttpSimpleController. it doesn't support parameters mapping. you can add your parameters to the query string or the body of requests.
    house-mouse
    @house-mouse
    Thanks for the quick reply!
    P.R.
    @prothegee

    Hi everyone,
    what is the equivalent of:

    auto cmd = R"(
        update public.account_verification_email set token_expired=true where email=$1;
    )";
    db->execSqlAsyncFuture(cmd, u_email);

    in drogon::orm ?

    <br>

    I tried:

    orm::Mapper<AccountVerificationEmail> aveMP(db);
    
    aveMP.updateFutureBy(
        AccountVerificationEmail::Cols::_token_expired,
            orm::Criteria(AccountVerificationEmail::Cols::_email,
            orm::CompareOperator::Like, u_email),
                true);

    but gets error:

    [build] /home/prg/backend/beCPP/db/postgresdb.h:326:53: note:   cannot convert ‘drogon_model::database_name::AccountVerificationEmail::Cols::_token_expired’ (type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’}) to type ‘const std::vector<std::__cxx11::basic_string<char> >&’
    [build]   326 |                     AccountVerificationEmail::Cols::_token_expired,
    [build]       |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~

    these column was actually boolean.

    Can someone correct me which part should be change?

    Raw sql command is fine, but I want to maximize using drogon orm.

    An Tao
    @an-tao
    The first parameter of the update method is a vector for updating multiple columns, try this:
    aveMP.updateFutureBy(
        {AccountVerificationEmail::Cols::_token_expired},
            orm::Criteria(AccountVerificationEmail::Cols::_email,
            orm::CompareOperator::Like, u_email),
                true);
    1 reply
    HadiAbbasi
    @HadiAbbasi
    Hi
    I wanna create a none-blocking parallel thread (maybe like future) as I wanna execute a scenario (function) with thread sleep (like change in a file after 30 seconds for my tests)!
    I didn't find any solution in drogon!
    even when I wanna use std::thread , there is an unknown error which stops drogon server!
    "terminate called without an active exception"
    could you please help me to find my solution?
    thanks a lot...
    All The Best,
    Hadi
    11 replies
    ammanabrolua
    @ammanabrolua
    hi
    is there a way to upload videos in drogon?
    please let me know of any examples
    Rafael Bugajewski
    @rbugajewski
    @ammanabrolua Did you already try with newFileUploadRequest? — https://drogon.docsforge.com/master/api/drogon/HttpRequest/newFileUploadRequest/
    And if you mean the other direction, then just take a look at the upload example — https://github.com/drogonframework/drogon/blob/master/examples/file_upload/file_upload.cc
    ammanabrolua
    @ammanabrolua
    How to navigate from one .csp to another. csp file?
    on click of button
    ?
    Please let me know
    Also, how to pass the data in this case?
    ammanabrolua
    @ammanabrolua
    How to create json array in drogon c++?
    1 reply
    ammanabrolua
    @ammanabrolua
    I have a question if video streaming possible in drogon?
    Ichiro
    @HadesD
    image.png
    @an-tao
    drogon doesnot support this?
    WojciechMigda
    @WojciechMigda
    Hi, if I were to use both drogon and boost.asio in a single program, is there a recommended way to do that, preferrably without launching separate threads for each?
    1 reply
    Suganthan BC
    @SuganthanBC

    I have a question if video streaming possible in drogon?

    I wonder the same

    An Tao
    @an-tao
    you could use the trantor::Logger::setOutputFunction() method to output drogon logs to your log system.
    Suganthan BC
    @SuganthanBC

    I am getting an error while trying to run drogon_ctl:

    drogon_ctl: error while loading shared libraries: libjsoncpp.so.25: cannot open shared object file: No such file or directory

    1 reply
    Does anybody have a clue on how to resolve this? I cloned jsoncpp on the $WORK_PATH
    and of course follwed all the instructions and did make && sudo make install
    mike
    @gnu-enjoyer
    when using a custom constructor HttpController w/ .registerController(ctrlPtr) before .run() the ctor runs OK but it doesn't seem to route the path e.g. /test as a GET method never calls the Controller's method. I've tried Cmake .. etc. to regenerate the proj am I missing something? I can get all the examples working so I'm thinking my issue is w/ the InitPathRouting stuff
    mike
    @gnu-enjoyer
    nvm think I fixed it by using ADD_METHOD_TO macro instead of METHOD_ADD
    TennisBowling
    @TennisBowling
    hey, how can I get a request's body?