Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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")
    An Tao
    @an-tao
    you could define a macro for that.
    HadiAbbasi
    @HadiAbbasi
    Hi there...
    I don't know Am I right or not!
    But I can't define a controller (handler) for empty path!
    ADD_METHOD_TO(PageCtrl::RootRout,"",{Get , Post , Put , Patch , Delete , Head});
    ADD_METHOD_TO(PageCtrl::RootRout,"/",{Get , Post , Put , Patch , Delete , Head});
    METHOD_ADD(PageCtrl::RootRout,"",{Get , Post , Put , Patch , Delete , Head});
    METHOD_ADD(PageCtrl::RootRout,"/",{Get , Post , Put , Patch , Delete , Head});
    and there is no any drogon action on root request like:
    http://mysite.com/
    Clément Gamé 🧠
    @WintermeW_twitter
    Hi, i have a little question regarding Filters and the request object ref passed as parameter: I implemented an authentication filter that is properly working except one thing: Whenever i try to inject some user claims in the request (userId, profile_type etc..) with the help of req->setParameter(param_name,value) for later use in my controllers, the other query params seem added by the user in the URL seem to disappear. Am i doing something wrong ? What is the correct way for a filter to inject data in the request for later reuse by the controllers ?
    Clément Gamé 🧠
    @WintermeW_twitter
    (note that i'd rather keep the auth mechanism sessionless)
    An Tao
    @an-tao
    @WintermeW_twitter you could use the attributes of a request object to do that.
    image.png
    Clément Gamé 🧠
    @WintermeW_twitter
    @an-tao ok great, thank you
    HadiAbbasi
    @HadiAbbasi
    Hi @an-tao
    Is it possible to remove or change content-length or content-type of response as we need to test the caching of our cnd (made by nginx)?
    In other words, I need to check the caching of my CDN for the while that there is no any cache-length on response headers and the origin server is drogon as there is no any limitation on (add/edit/remove headers on) it!
    removeHeader method was not able to remove content-length!
    I know that removing some headers like Content-Length can be dangerous but is there any solution for my problem?
    All The Best,
    Hadi
    Maurice Barnett
    @r3cebarnett
    Apologies if this has already been answered somewhere. If I wanted to do a soft restart (without killing the parent process) of an application using Drogon, how might I cleanly resume Drogon?
    It looks like drogon::app() returns a singleton and I can't find a way to reset it. I also tried to create my own instance of an HttpAppFramework object using newbut it seg faults upon deletion.
    An Tao
    @an-tao

    Hi @an-tao
    Is it possible to remove or change content-length or content-type of response as we need to test the caching of our cnd (made by nginx)?
    In other words, I need to check the caching of my CDN for the while that there is no any cache-length on response headers and the origin server is drogon as there is no any limitation on (add/edit/remove headers on) it!
    removeHeader method was not able to remove content-length!
    I know that removing some headers like Content-Length can be dangerous but is there any solution for my problem?
    All The Best,
    Hadi

    currently you can't do that, you need to change drogon code to achieve that.

    3 replies

    Apologies if this has already been answered somewhere. If I wanted to do a soft restart (without killing the parent process) of an application using Drogon, how might I cleanly resume Drogon?

    There is no API of drogon to do that, you have to change drogon code to achieve that. please refer to the run() method of drogon::app().

    An Tao
    @an-tao
    34bb5dfa8eb48d33aaa91c2f603bf30.jpg
    @HadiAbbasi You don't need to define a route for an empty path as it is equivalent to "/"
    3 replies
    1111mp
    @1111mp
    image.png
    When I customize the filter, the lambda function passes the fccb execution causing the program to crash
    image.png
    Assertion failed: (idx < storage_.size()), function getThreadData, file IOThreadStorage.h, line 100.
    can someone help me
    please
    thank you very much
    1111mp
    @1111mp
    Probably know the reason, here you need to use the synchronous execCommandSync method.
    An Tao
    @an-tao
    you should use the fast redis client to ensure that the storage is accessed in IO threads (not in the thread used by redis client)
    jamal rashidi
    @jamalrashidi1_twitter

    hello
    I have a problem with Trantor on Windows compiled with MSVC 2017 x64. I got the below error when running a simple TCP server using Trantor :

    ERROR SO_REUSEPORT is not supported.

    An Tao
    @an-tao
        TcpServer(EventLoop *loop,
                  const InetAddress &address,
                  const std::string &name,
                  bool reUseAddr = true,
                  bool reUsePort = true);
    you can set the last parameter to false
    5 replies
    Okami チム
    @okami.mks:matrix.org
    [m]
    installing vcpkg was a struggle, XD
    demenkovms
    @demenkovms

    Hello. I create controller by command: drogon_ctl create controller PingController:

    PingController.h:

     #pragma once
     #include <drogon/HttpSimpleController.h>
     using namespace drogon; 
     class PingController : public drogon::HttpSimpleController<PingController>
     {
      public:
        virtual void asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback) override;
        PATH_LIST_BEGIN
         PATH_ADD("/PING", Get);
        PATH_LIST_END
     };

    PingController.c:

    #include "PingController.h"
    
    void PingController::asyncHandleHttpRequest(const HttpRequestPtr& req, std::function<void (const HttpResponsePtr &)> &&callback)
    {
        // write your application logic here
    
        auto resp = HttpResponse::newHttpResponse();
        resp->setStatusCode(k200OK);
        resp->setContentTypeCode(CT_TEXT_HTML);
        resp->setBody("PONG");
        callback(resp);
    
    }

    but when I try to call http://localhost/PING i get 404 Not Found

    An Tao
    @an-tao
    did you re-cmake your project after adding this controller?
    demenkovms
    @demenkovms
    yes, of course )