Comments (4)
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.
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.
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.
Hi @lganzzzo,
I found using this way I cannot set the path variable through Swagger, an example is like
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from example-async-api.