QHttpServer - middleware /route pre-process?
-
wrote on 22 Jul 2024, 22:38 last edited by
Hey
I may be mistaken as to middleware... but is there a way to set up route pre process/middleware?Say I want to validate request before pushing it to /XX/XX route.
Is there a way to install it in current lib/server?
Or I need to build my own kind-of-wrapper?
Regards
Dariusz -
Hi,
apologies, but I fail to understand what your question is.
BRgds
Axel -
Hi,
I am currently unsure but I don't think that QHttpServer provides directly that kind of low level facility.
Depending on your end goal, the Cutelyst project might be a better option.
-
Hi,
apologies, but I fail to understand what your question is.
BRgds
Axelwrote on 23 Jul 2024, 22:27 last edited by Dariusz@Axel-Spoerl essentially it goes something like this if I remember correctly...
void middleWareAuth(QNetworkRequest *request ){ /// Perform login check. request.setXX/YY if need to. return True if accept/False if ignore request/stop action. } // Order of route/middleware registration matters. server.addMiddleware(&someSpamProtection) // as example. server.route("/api/login") // we allow for login access from anywhere server.addMiddleware(&middleWareAuth) // anything after this has to be logged in server.route("/api/userAccount") // only call when user/request is verified as logged/cokie/auth etc.
Hope this makes somehow sense...
@SGaist Yep hear of that lib, however I'm trying to stick to official Qt libs only, seeing as then my plugins/etc will work out of the box on DCC apps (maya/vred/nuke/etc/etc)
-
@Axel-Spoerl essentially it goes something like this if I remember correctly...
void middleWareAuth(QNetworkRequest *request ){ /// Perform login check. request.setXX/YY if need to. return True if accept/False if ignore request/stop action. } // Order of route/middleware registration matters. server.addMiddleware(&someSpamProtection) // as example. server.route("/api/login") // we allow for login access from anywhere server.addMiddleware(&middleWareAuth) // anything after this has to be logged in server.route("/api/userAccount") // only call when user/request is verified as logged/cokie/auth etc.
Hope this makes somehow sense...
@SGaist Yep hear of that lib, however I'm trying to stick to official Qt libs only, seeing as then my plugins/etc will work out of the box on DCC apps (maya/vred/nuke/etc/etc)
wrote on 23 Jul 2024, 22:34 last edited by@Dariusz if I understand correctly you need to write yourself a wrapper (or a separate gateway class for creating and submitting requests) around QNAM. As far as I can tell there is no such analytical proxy-like thing built in.
Mind you, usually where those things are needed you do have a gateway/proxy prohibiting traffic or redirecting it accordingly. But I also thing I understand the need, so I'll stick with the idea of wrapping QNAM in a more tailored fashion.
-
@Dariusz if I understand correctly you need to write yourself a wrapper (or a separate gateway class for creating and submitting requests) around QNAM. As far as I can tell there is no such analytical proxy-like thing built in.
Mind you, usually where those things are needed you do have a gateway/proxy prohibiting traffic or redirecting it accordingly. But I also thing I understand the need, so I'll stick with the idea of wrapping QNAM in a more tailored fashion.
-
wrote on 24 Jul 2024, 08:40 last edited by
@SGaist perhaps. My imagined wrapper simply holds the QNAM inside exposing request() and finished() slots/signals (in general), doing all the examinations inside and then sending requests. So, a gateway to replacing QNAM altogether in a sense.
1/7