Git Product home page Git Product logo

Comments (4)

lganzzzo avatar lganzzzo commented on May 26, 2024 1

Hello @ReturnHttp418 ,

If you are using Async API - you have to manually add all swagger params inside the ENDPOINT_INFO block.

Also, I will receive [ApiController]: Error. Non-async call to async endpoint. when switching to the async endpoint. Do you know what's it about?

If you are using Async Endpoints, you have to use AsyncHttpConnectionHandler.

from example-async-api.

puneetugru avatar puneetugru commented on May 26, 2024

I'm able to get the path parameters below way,

ENDPOINT_ASYNC("POST", "{path-param1}/{path-param2}/temperature", getTemperature) {

           ENDPOINT_ASYNC_INIT(getTemperature)
           String pathParam1;
           String pathParam2;
    
           Action act() override {
                pathParam1 = request->getPathVariable("path-param1");
                pathParam2 = request->getPathVariable("path-param2");
                return request->readBodyToDtoAsync<DataDto>(controller->getDefaultObjectMapper())
                   .callbackTo(&getTemperature::onBodyObtained);
           }

           Action onBodyObtained(const DataDto::ObjectWrapper& dataDto) {   
    
               OATPP_LOGD("MyApp", "Received nodeId value=%s", pathParam1->std_str().c_str());
               OATPP_LOGD("MyApp", "Received sensorId value=%s", pathParam2->std_str().c_str());
               OATPP_LOGD("MyApp", "Received value for type=%s", dataDto->type->std_str().c_str());
               OATPP_LOGD("MyApp", "Received value for timestamp=%ld", dataDto->timestamp->getValue());
               OATPP_LOGD("MyApp", "Received value for temperature=%lf", dataDto->temperature->getValue());

               /* return result */
               return _return(controller->createDtoResponse(Status::CODE_202, dataDto));
          }
   };

But, can you tell me whether this is correct or something needs to be changed further?

  • Thanks,
    Puneet Ugru

from example-async-api.

lganzzzo avatar lganzzzo commented on May 26, 2024

Hello @puneetugru ,

Yes you are correct - this is the right way to get path variables when using ENDPOINT_ASYNC.

param = request->getPathVariable("path-param-name");

Best Regards,
Leonid

from example-async-api.

ReturnHttp418 avatar ReturnHttp418 commented on May 26, 2024

Hi @lganzzzo,

I found using this way I cannot set the path variable through Swagger, an example is like
image
Do I have any options to change this?

Also, I will receive [ApiController]: Error. Non-async call to async endpoint. when switching to the async endpoint. Do you know what's it about?

Thanks

from example-async-api.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.