Re: triggering servlet on GET parameters
Jay McCarthy <[email protected]>
| Newsgroups | gmane.comp.lang.racket.user,gmane.lisp.scheme.plt |
|---|---|
| Message-ID | <CAJYbDam6mw4ZC5QU+UJYvdWzxYMGvFdmbg4-LHKw4viogcisug@mail.gmail.com> |
You can use web-server/servlet and you don't need to use web-server/dispatch if you don't want to. Your design seems good to me. On Sun, Jan 6, 2019 at 10:33 AM Stephen De Gabrielle <[email protected]> wrote: > > Thank you Jay and David, > > Your suggestions were good, #:servlet-regexp #rx"" lets me capture the request for a page and server the original file, or the edit servlet: > http://localhost:8000/mouse.html > http://localhost:8000/mouse.html?action=edit > > I've been reading a little more and I think I've made a mistake! I'm using 'Stateful Servlets'(require web-server/servlet), and I *think* I should be using (require web-server/dispatch), so I can capture the situation where a static file is not found. > > Do you think web-server/dispatch is the right approach? > > My design is; > > GET http(s)://server/<filename in #:server-root-path> > -> serve static file at specified path > GET http(s)://server/<filename in #:server-root-path>?action=edit > -> serve edit page servlet that retrieves scribble source > GET http(s)://server/<filename not found in #:server-root-path> > -> serve edit page adding parameters ?action=edit or maybe new > POST http(s)://server/<filename in #:server-root-path> > -> update scribble source file, generate target html file in #:server-root-path and redirect to target html file at http(s)://server/<filename in #:server-root-path> > > > > On Thu, Jan 3, 2019 at 4:35 PM David Storrs <[email protected]> wrote: >> >> Stephen, you might also find this useful as a reference to crib from: http://matt.might.net/articles/low-level-web-in-racket/ >> >> On Thu, Jan 3, 2019 at 11:10 AM Jay McCarthy <[email protected]> wrote: >>> >>> Use normal racket/base and web-server/servlet-env ‘s serve/servlet >>> >>> On Thu, Jan 3, 2019 at 10:53 AM David Storrs <[email protected]> wrote: >>>> >>>> >>>> >>>> On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy <[email protected]> wrote: >>>>> >>>>> You need to stop using `web-server/insta` >>>> >>>> >>>> What would you recommend he use instead of web-server/insta? >>>> >>>>> >>>>> so you can customize more. >>>>> Then, you need to intercept ALL requests with your servlet. Then, your >>>>> servlet just needs to call (next-dispatcher) and the static file >>>>> handler will kick in, because it comes after servlets. >>>>> >>>>> Jay >>>>> >>>>> On Wed, Jan 2, 2019 at 7:08 PM Stephen De Gabrielle >>>>> <[email protected]> wrote: >>>>> > >>>>> > Hi, >>>>> > >>>>> > I'm fooling around with #lang web-server/insta, and I can serve .html files by setting (static-files-path page-root), but I'd like to trigger my servlet if there is a '?action=edit' parameter set. >>>>> > >>>>> > e.g >>>>> > https://localhost/start.html just serves the file (I can do this!) >>>>> > https://localhost/start.html?action=edit calls my servlet (I can't work out how to do this :( ) >>>>> > >>>>> > (There is a lot of documentation but I'm a beginner with webdev so don't know where to look) >>>>> > >>>>> > Kind regards >>>>> > >>>>> > Stephen >>>>> > >>>>> > PS the project is a scribble based wiki. If you create a new page you enter raw scribble/manual in a form (my servlet) and it gets saved in a folder and transformed into html that is served directly by (static-files-path page-root), the conversion from raw scribble goes like this: >>>>> > (require raco/all-tools) >>>>> > (define raco-scribble-spec (hash-ref (all-tools) "scribble")) >>>>> > ;;scribble-to-html : source target body >>>>> > ;; generate html file from scribble file >>>>> > (define (scribble-to-html source target) ;-> list of strings >>>>> > (parameterize ([current-command-line-arguments (vector "--html" source)] >>>>> > [current-directory target]) >>>>> > (dynamic-require (cadr raco-scribble-spec) #f))) >>>>> > >>>>> > >>>>> > -- >>>>> > You received this message because you are subscribed to the Google Groups "Racket Users" group. >>>>> > To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] >>>>> > For more options, visit https://groups.google.com/d/optout. >>>>> >>>>> >>>>> >>>>> -- >>>>> -=[ Jay McCarthy http://jeapostrophe.github.io ]=- >>>>> -=[ Associate Professor PLT @ CS @ UMass Lowell ]=- >>>>> -=[ Moses 1:33: And worlds without number have I created; ]=- >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google Groups "Racket Users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] >>>>> For more options, visit https://groups.google.com/d/optout. >>> >>> -- >>> -=[ Jay McCarthy http://jeapostrophe.github.io ]=- >>> -=[ Associate Professor PLT @ CS @ UMass Lowell ]=- >>> -=[ Moses 1:33: And worlds without number have I created; ]=- > > -- > ---- -- -=[ Jay McCarthy http://jeapostrophe.github.io ]=- -=[ Associate Professor PLT @ CS @ UMass Lowell ]=- -=[ Moses 1:33: And worlds without number have I created; ]=- -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.