Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    nobody
    @nobody93
    are there any dragon email discussion forum or mailing list for help?
    Rafael Bugajewski
    @rbugajewski
    @nobody93 What exactly do you mean by “displaying background images”? You can certainly use HTML/CSS in the CSP templates, and also combine these with parameters passed in from controllers.
    nobody
    @nobody93
    @rbugajewski, sorry I am new here, is there a demo to use HTML/CSS in the CSP templates? I am learning from drogon/examples currently, could not find an example for it, nor tutorial from WiKi
    nobody
    @nobody93
    Is the ENG 04 1 Controller HttpSimpleController did you refer to? Tried it, but no idea how to complete the code
    I was looking for a simple web application example to display background image and to rotate images automatically in defined time interval.
    nobody
    @nobody93
    According to the WiFi, to run CSP, it should compile with -DCMAKE_ENABLE_EXPORTS=on, but after running it, I could not find dynamic libraries with *.so, what could I be missing?
    Rafael Bugajewski
    @rbugajewski
    @nobody93 I’m not sure what you’re referring to, but you can check out the simple Hello World example, at https://github.com/drogonframework/drogon/blob/master/examples/helloworld/HelloView.csp
    You can add images like in normal HTML documents, see for example https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Img
    And if you want to rotate them in a defined time interval (and automatically display it on the client) you will have to use client-side code in JavaScript, or otherwise reload the whole page, not only redisplay the rotated image.
    P.R.
    @prothegee
    Hello, does anyone know where to get current port access from json listener when domain.tld/foo/bar is been requested?
    An Tao
    @an-tao
    requestPtr->localAddr()
    P.R.
    @prothegee
    requestPtr->localAddr()
    Owh yess, work nicely! Thanks, @an-tao
    Meir Yanovich
    @meiry
    hello all
    i have problem creating new drogon project both windows and linux
    nobody
    @nobody93
    I build with -DCMAKE_ENABLE_EXPORTS=on in ubuntu 18.04, but I could not find dynamic libraries with .so, I only got 2 static libraries libdrogon.a libtrantor.a, how can I build dynamic libraries with .so?
    HadiAbbasi
    @HadiAbbasi

    Hey Guys
    Just a simple question!
    this is a test for me!
    I wanna bind a callback to specific port!
    in other words, I need to make conditions on port numbers to send related response to client that sends request to specific port!
    as you can see, we can just add some listeners having ip , port!
    But addListener method has no any callback args!

    
    drogon::app().addListener("0.0.0.0",20001);
    drogon::app().addListener("0.0.0.0",20002);
    drogon::app().addListener("0.0.0.0",20003);
    
    drogon::HttpAppFramework::instance().registerHandler("/index",
                            [=](const drogon::HttpRequestPtr &req , 
                                std::function<void (const drogon::HttpResponsePtr &)> &&callback)
                            {
                                if (req ->port == 20001)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img01.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                                else if (req ->port == 20002)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img02.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                                else if (req ->port == 20003)
                                {
                                    auto resp = drogon::HttpResponse::newFileResponse("/path/to/img03.jpg", "", drogon::ContentType::CT_IMAGE_JPG);
                                    callback(resp);
                                }
                            });

    in the top example, req->port has error because req has no any port member!
    so I don't know how can I set conditions or bind callbacks on ports!
    All The Best,
    Hadi

    3 replies
    slaught3red
    @slaught3red:matrix.org
    [m]
    hey guys, could someone please help me out? so i'm having a problem while installing drogon via VCPKG: error: building openssl:x86-windows failed with: BUILD_FAILED. it seems that openssl must be installed as a drogo dependency but [dot]us servers are unreachable for me. so then i manually installed the openssl package but the vcpkg doesn't see it in downloaded folder for some reason. vcpkg list command doesn't seem to detect openssl file too. idk what to do =)
    slaught3red
    @slaught3red:matrix.org
    [m]
    oh nevermind i just managed to fix it =) sry for the inconvenience
    Clément Gamé 🧠
    @WintermeW_twitter
    Hi, i would like to implement a session-less authentication with verification of an api key sent in a request header, and i was planning to use a registerPreHandlingAdvice hook in order to achieve this but i have a few questions. 1. Is it the correct way to go ? I mean, the point is that i don't want to inject the key verification routine in each method of each controller which requires authentication (it makes a lot of them) 2. Would i be able to return a 403 forbidden as a final response if key is invalid, from the registerPreHandlingAdvice callback ? Thank you
    An Tao
    @an-tao
    Yes, you can do that
    or you could implement that via a Filter
    Clément Gamé 🧠
    @WintermeW_twitter
    Ok cool, i'll look into filters thank you :)
    An Tao
    @an-tao
    NP:)
    Clément Gamé 🧠
    @WintermeW_twitter
    @an-tao Is it theorically possible to use asynchronous code inside a doFilter and call fccb() from the done callback (fccb being captured by the lambda of the callback) because it seems to cause me troubles:
    /usr/src/drogon/lib/inc/drogon/IOThreadStorage.h:100: drogon::IOThreadStorage<C>::ValueType& drogon::IOThreadStorage<C>::getThreadData() [with C = std::shared_ptr<drogon::HttpResponse>; drogon::IOThreadStorage<C>::ValueType = std::shared_ptr<drogon::HttpResponse>]: Assertion `idx < storage_.size()' failed.
    Clément Gamé 🧠
    @WintermeW_twitter
    Indeed putting my code back in synchronous mode makes it work without any issue (no runtime error)
    kapilpipaliya
    @kapilpipaliya
    how to disable Ctrl+C feature? when I press Ctrl+C it shouldn't quit. It shouldn't handle anything like that.
    An Tao
    @an-tao

    /usr/src/drogon/lib/inc/drogon/IOThreadStorage.h:100: drogon::IOThreadStorage<C>::ValueType& drogon::IOThreadStorage<C>::getThreadData() [with C = std::shared_ptr<drogon::HttpResponse>; drogon::IOThreadStorage<C>::ValueType = std::shared_ptr<drogon::HttpResponse>]: Assertion `idx < storage_.size()' failed.

    The error usually means the done callback is not in an IO threads of drogon. if you use dbClients, please use the Fast database clients, because it uses the IO threads.

    how to disable Ctrl+C feature? when I press Ctrl+C it shouldn't quit. It shouldn't handle anything like that.
     /// Disable the handling of SIGTERM signal.
        /**
         * Enabled by default.
         *
         * @note
         * This operation can be performed by an option in the configuration file.
         * When disabled setTermSignalHandler() is useless
         */
        virtual HttpAppFramework &disableSigtermHandling() = 0;
    kapilpipaliya
    @kapilpipaliya
    Thank you so much
    deltine
    @deltine
    image.png
    Is it possible to implement multiple APIs on one PC?
    An Tao
    @an-tao
    You can create two applications for that.
    1 reply
    Ichiro
    @HadesD
    anybody is working on drogon 2.0?
    Rafael Bugajewski
    @rbugajewski
    I think the current focus is still on 1.x, correct me if I’m wrong.
    Stockwizard
    @Stockwizard
    Where is file #include <trantor/exports.h>?
    An Tao
    @an-tao
    it's generated by cmake.
    wrong car why
    @minatozaki:matrix.org
    [m]
    Hi. I have read the documentation of Drogon and it is my first time using it, and c++ in general. I was just wondering, can someone help me on how to connect my mysql database and access it on Postman for CRUD? any help would be appreciated. thank you!
    3 replies
    Omar Mohamed Khallaf
    @OmarMohamedKhallaf
    I was wondering whether I can use co_routines with HttpController or not ?
    I feel drogon::app().registerHandler() isn't the right way to do this.
    An Tao
    @an-tao
    you can do that when declaring handler as correct API.
    4 replies
    An Tao
    @an-tao
    image.png
    Arun Chandrasekaran
    @carun
    image.png
    1 reply
    Hi all, I'm trying to build a simple app and I'm seeing this error:
    My CMakeLists.txt looks something like this:
    project(Mozart)
    cmake_minimum_required(VERSION 3.14)
    
    cmake_policy(SET CMP0015 NEW)
    if(POLICY CMP0074)
        cmake_policy(SET CMP0074 NEW)
    endif()
    
    if(NOT CMAKE_BUILD_TYPE)
        set(CMAKE_BUILD_TYPE Debug)
    endif()
    
    list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
    add_custom_target(fetch_packages)
    
    set(CMAKE_CXX_STANDARD 20)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    set(CMAKE_CXX_EXTENSIONS OFF)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
    add_definitions(-DNOMINMAX)
    
    add_definitions(-DCOMMIT="${GIT_COMMIT_HASH}")
    
    if(ENABLE_ASAN)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=address,undefined")
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address,undefined")
    endif()
    
    if(ENABLE_TSAN)
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
        set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
    endif()
    
    include(GitRevision)
    include(FetchContent)
    
    # Open source libraries
    find_package(Boost REQUIRED)
    find_package(Git REQUIRED)
    find_package(Drogon REQUIRED)
    
    include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
    include_directories(SYSTEM ${json_INCLUDE_DIR})
    include_directories(SYSTEM ${CMAKE_BINARY_DIR})
    
    link_directories(${Boost_LIBRARY_DIRS})
    link_directories(${Boost_LIBRARIES})
    
    add_subdirectory(src)
    
    include(cmake/Docker.cmake)
    what could I be doing wrong
    HadiAbbasi
    @HadiAbbasi

    Hello
    Is it possible to define PATH_ADD with regular expression on input path (as regex-pattern)?
    suppose that I wanna create a dynamicFileLoaderCtrl which can load files, So it can send response to client dynamically!
    I don't want bind some specific static URLs in my controller!
    and it must load the ordered file if it exists, otherwise it must callback error 404!
    just I wanna know regex on PATH_ADD possibility!

    
    PATH_ADD_VIA_REGEX("/*.*",Get,Post);
    
    //get request info & load & send file to client

    Thanks A Lot...
    All The Best,
    Hadi

    An Tao
    @an-tao
    Hi,you can use the ADD_METHOD_VIA_REGEX macro to achieve that.
    5 replies
    Ichiro
    @HadesD
    can i make a nested route for drogon likes laravel
    Route::group('/parent', function() {
      Route::get('/child1', classA@index);
      Route::get('/child2', classB@index);
    })->middleware('auth');
    cause I want to set filter login to all child route, not like this
    DROGON_ROUTE("/parent/child1", functionBind1, "auth")
    DROGON_ROUTE("/parent/child2", functionBind2, "auth")