Open pranav-joshi opened 1 year ago
Could you maybe add some more info on what you want to do? It looks like you are trying to do something complicated that could maybe be solved in a much easier way.
It looks like you are trying to create a custom response.
But that is what this crate/package does for you. Maybe take a look at this (or the other) example.
This shows you how you can use this package.
https://github.com/GREsau/okapi/blob/345e11769759db84beb35c5d47daccdc381acf9e/examples/json-web-api/src/main.rs
You mostly just define a struct
of some kind and use that as a function return parameter.
As you see here: https://github.com/GREsau/okapi/blob/345e11769759db84beb35c5d47daccdc381acf9e/examples/json-web-api/src/main.rs#L27
if you want it to be optional (not required) you can use Option<_>
as you see here:
https://github.com/GREsau/okapi/blob/345e11769759db84beb35c5d47daccdc381acf9e/examples/json-web-api/src/main.rs#L40
If you have questions, feel free to ask!
example code: [Note - I have added the references correctly. Also, I am new to Rust, sorry in advance for my naiveite]