Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QHttpServer - middleware /route pre-process?
Forum Update on Monday, May 27th 2025

QHttpServer - middleware /route pre-process?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 393 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on 22 Jul 2024, 22:38 last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 23 Jul 2024, 17:37 last edited by
      #2

      Hi,
      apologies, but I fail to understand what your question is.
      BRgds
      Axel

      Software Engineer
      The Qt Company, Oslo

      D 1 Reply Last reply 23 Jul 2024, 22:27
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 23 Jul 2024, 18:49 last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • A Axel Spoerl
          23 Jul 2024, 17:37

          Hi,
          apologies, but I fail to understand what your question is.
          BRgds
          Axel

          D Offline
          D Offline
          Dariusz
          wrote on 23 Jul 2024, 22:27 last edited by Dariusz
          #4

          @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)

          A 1 Reply Last reply 23 Jul 2024, 22:34
          0
          • D Dariusz
            23 Jul 2024, 22:27

            @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)

            A Offline
            A Offline
            artwaw
            wrote on 23 Jul 2024, 22:34 last edited by
            #5

            @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.

            For more information please re-read.

            Kind Regards,
            Artur

            S 1 Reply Last reply 24 Jul 2024, 06:36
            0
            • A artwaw
              23 Jul 2024, 22:34

              @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.

              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 24 Jul 2024, 06:36 last edited by
              #6

              @artwaw I think you have it the wrong way around, QNAM is to make outgoing requests, here, @Dariusz is building the server side.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply 24 Jul 2024, 08:40
              0
              • S SGaist
                24 Jul 2024, 06:36

                @artwaw I think you have it the wrong way around, QNAM is to make outgoing requests, here, @Dariusz is building the server side.

                A Offline
                A Offline
                artwaw
                wrote on 24 Jul 2024, 08:40 last edited by
                #7

                @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.

                For more information please re-read.

                Kind Regards,
                Artur

                1 Reply Last reply
                0

                1/7

                22 Jul 2024, 22:38

                • Login

                • Login or register to search.
                1 out of 7
                • First post
                  1/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved