Re: [racket-users] triggering servlet on GET parameters

2019-01-13 Thread Stephen De Gabrielle
Apologies - I’ve changed it to public - >
https://github.com/spdegabrielle/clash/blob/master/main.rkt

On Mon, 14 Jan 2019 at 06:14, Jesse Alama  wrote:

> Hi Stephen,
>
> On 13 Jan 2019, at 13:21, Stephen De Gabrielle wrote:
>
> > On the bright side I have the basic thing working:
> > https://github.com/spdegabrielle/clash/blob/master/main.rkt
>
> I get a 404 here.
>
> Jesse
>
-- 


-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-13 Thread Stephen De Gabrielle
Thank you Jay, Matthew, Jesse & David,

I'm still looking at the resources your referred me to - they are much
appreciated.

On the bright side I have the basic thing working:
https://github.com/spdegabrielle/clash/blob/master/main.rkt

I'm trying to build a very basic wiki using scribble as the wiki text!
(to replace https://github.com/racket/racket/wiki)

If you have time or are interested I'd appreciate feedback on my code.

Kind regards,
Stephen


On Tue, Jan 8, 2019 at 4:55 AM Jesse Alama  wrote:

> On 7 Jan 2019, at 0:16, Matthew Butterick wrote:
>
> > Don't know if it would be an instructive example, but the Pollen
> > project server [1], though not intended for production use, is a
> > self-contained HTTP server that handles dynamic generation of HTML (it
> > even works with Scribble files), which sounds similar to what you're
> > trying to do.
> >
> > Jesse Alama's book Server: Racket [2] is an excellent resource. Among
> > many other things, I learned that you can invent arbitrary HTTP
> > methods beyond GET and POST, thereby avoiding encoding conventions
> > like "?action=edit". Instead, you can just have an HTTP method called
> > EDIT.
>
> In Stephen's case, I think the classical HTTP method PUT is a good
> match. PUT is intended to mean, roughly (precise definition at [1]):
> here, take this request body; *it* will be the content in response
> bodies to GET requests for this URL from now on.
>
> One of my favorite examples of custom (non-canonical) HTTP methods is
> for "cancelling" something (an order, an edit, some item of some group).
>
>CANCEL https://example.com/order/4567
>
> I find this method-URL pair more palatable than something like
>
>POST https://example.com/cancel/order/4567
>
> where the action (cancelling) is part of the URL.
>
> Alas, not all browsers support such HTTP methods (such requests may get
> silently converted into POSTs, despite your wishes), so they tend to be
> relevant only in scenarios where you're using programmable HTTP clients
> (e.g., command line tools such as cURL or Httpie [2], or libraries such
> as Greg Hendershott's http [3]).
>
> Jesse
>
> [1] https://tools.ietf.org/html/rfc2616#section-9.6
>
> [2] https://httpie.org
>
> [3] https://pkgs.racket-lang.org/package/http
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-07 Thread Jesse Alama

On 7 Jan 2019, at 0:16, Matthew Butterick wrote:

Don't know if it would be an instructive example, but the Pollen 
project server [1], though not intended for production use, is a 
self-contained HTTP server that handles dynamic generation of HTML (it 
even works with Scribble files), which sounds similar to what you're 
trying to do.


Jesse Alama's book Server: Racket [2] is an excellent resource. Among 
many other things, I learned that you can invent arbitrary HTTP 
methods beyond GET and POST, thereby avoiding encoding conventions 
like "?action=edit". Instead, you can just have an HTTP method called 
EDIT.


In Stephen's case, I think the classical HTTP method PUT is a good 
match. PUT is intended to mean, roughly (precise definition at [1]): 
here, take this request body; *it* will be the content in response 
bodies to GET requests for this URL from now on.


One of my favorite examples of custom (non-canonical) HTTP methods is 
for "cancelling" something (an order, an edit, some item of some group).


  CANCEL https://example.com/order/4567

I find this method-URL pair more palatable than something like

  POST https://example.com/cancel/order/4567

where the action (cancelling) is part of the URL.

Alas, not all browsers support such HTTP methods (such requests may get 
silently converted into POSTs, despite your wishes), so they tend to be 
relevant only in scenarios where you're using programmable HTTP clients 
(e.g., command line tools such as cURL or Httpie [2], or libraries such 
as Greg Hendershott's http [3]).


Jesse

[1] https://tools.ietf.org/html/rfc2616#section-9.6

[2] https://httpie.org

[3] https://pkgs.racket-lang.org/package/http

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-07 Thread Jay McCarthy
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
 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/
> -> serve static file at specified path
> GET http(s)://server/?action=edit
> -> serve edit page servlet that retrieves scribble source
> GET http(s)://server/
> -> serve edit page adding parameters ?action=edit or maybe new
> POST http(s)://server/
> -> update scribble source file,  generate target html file in 
> #:server-root-path and redirect to target html file at 
> http(s)://server/
>
>
>
> On Thu, Jan 3, 2019 at 4:35 PM David Storrs  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  wrote:
>>>
>>> Use normal racket/base and web-server/servlet-env ‘s serve/servlet
>>>
>>> On Thu, Jan 3, 2019 at 10:53 AM David Storrs  wrote:



 On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy  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
>  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+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
>>> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
>>> -=[ Moses 1:33: And worlds without number have I created; ]=-
>
> --
> 



-- 
-=[ Jay McCarthy   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

-- 
You received this message because you 

Re: [racket-users] triggering servlet on GET parameters

2019-01-06 Thread Matthew Butterick
Don't know if it would be an instructive example, but the Pollen project server 
[1], though not intended for production use, is a self-contained HTTP server 
that handles dynamic generation of HTML (it even works with Scribble files), 
which sounds similar to what you're trying to do.

Jesse Alama's book Server: Racket [2] is an excellent resource. Among many 
other things, I learned that you can invent arbitrary HTTP methods beyond GET 
and POST, thereby avoiding encoding conventions like "?action=edit". Instead, 
you can just have an HTTP method called EDIT.

It's possible to use the Racket web server "behind" Apache, so that Apache 
handles the static file serving, and Racket handles computation. [3] 

[1] 
https://github.com/mbutterick/pollen/blob/master/pollen/private/project-server.rkt

[2] https://serverracket.com/

[3] 
http://docs.racket-lang.org/web-server-internal/Troubleshooting_and_Tips.html?q=apache#%28part._.How_do_.I_use_.Apache_with_the_.Racket_.Web_.Server_%29

> On Jan 6, 2019, at 7:33 AM, Stephen De Gabrielle  
> wrote:
> 
> Do you think web-server/dispatch is the right approach?
> 
> My design is; 
> 
> GET http(s)://server/ 
> -> serve static file at specified path
> GET http(s)://server/?action=edit 
> -> serve edit page servlet that retrieves scribble source
> GET http(s)://server/ 
> -> serve edit page adding parameters ?action=edit or maybe new
> POST http(s)://server/   
> -> update scribble source file,  generate target html file in 
> #:server-root-path and redirect to target html file at 
> http(s)://server/https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-06 Thread Stephen De Gabrielle
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/
-> serve static file at specified path
GET http(s)://server/?action=edit
-> serve edit page servlet that retrieves scribble source
GET http(s)://server/
-> serve edit page adding parameters ?action=edit or maybe new
POST http(s)://server/
-> update scribble source file,  generate target html file in
#:server-root-path and redirect to target html file at
http(s)://server/



On Thu, Jan 3, 2019 at 4:35 PM David Storrs  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 
> wrote:
>
>> Use normal racket/base and web-server/servlet-env ‘s serve/servlet
>>
>> On Thu, Jan 3, 2019 at 10:53 AM David Storrs 
>> wrote:
>>
>>>
>>>
>>> On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy 
>>> 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
  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+unsubscr...@googlegroups.com.
 > For more options, visit https://groups.google.com/d/optout.



 --
 -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
 -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>> --
>> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
>> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-04 Thread Jesse Alama

Hi Stephen,

On 3 Jan 2019, at 1:07, Stephen De Gabrielle wrote:

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)


This doesn't work (in the sense that it is deliberately incomplete or 
broken), but just to elaborate on what Jay is suggesting, here's how I 
might get started on this kind of project:


#lang racket

(require net/url
 web-server/http
 web-server/servlet-env)

(define/contract (url->action url)
  (url? . -> . (or/c false/c string?))
  (define (action? x)
(eq? 'action (car x)))
  (define result (assoc 'action (url-query url)))
  (cond [(pair? result)
 (bytes->string/utf-8 (cdr result))]
[else
 #f]))

; build a path for interpreting the URL
; as pointing to something on the disk
(define/contract (url->path url)
  (url? . -> . path?)
  (apply build-path
 (map path/param-path (url-path url

(define/contract (edit-file p)
  (path? . -> . response?)
  (define ip (open-input-file p))
  (define response-body
`(html
  (head
   (title "Edit"))
  (body
   (form
((action "/save-file")
 (method "post"))
(textarea ,(path->string ip))
  (response/xexpr response-body))

(define/contract (save-file req)
  (request? . -> . response?)
  ;; process the changed file and generate a response
  1
  )

(define (start req)
  (define url (request-uri req))
  (define path (url->path url))
  (define action (url->action url))
  (cond [(string? action)
 (edit-file path)]
[else
 ((url->path url))
 ]))

(serve/servlet
 start
 #:servlet-path ""
 #:servlet-regexp #rx"")

--
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-03 Thread David Storrs
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  wrote:

> Use normal racket/base and web-server/servlet-env ‘s serve/servlet
>
> On Thu, Jan 3, 2019 at 10:53 AM David Storrs 
> wrote:
>
>>
>>
>> On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy 
>> 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
>>>  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+unsubscr...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
>>> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-03 Thread Jay McCarthy
Use normal racket/base and web-server/servlet-env ‘s serve/servlet

On Thu, Jan 3, 2019 at 10:53 AM David Storrs  wrote:

>
>
> On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy 
> 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
>>  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+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
>> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
-=[ Jay McCarthy   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-03 Thread David Storrs
On Wed, Jan 2, 2019 at 7:12 PM Jay McCarthy  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
>  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+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> -=[ Jay McCarthy   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] triggering servlet on GET parameters

2019-01-02 Thread Jay McCarthy
You need to stop using `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
 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+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
-=[ Jay McCarthy   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ 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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] triggering servlet on GET parameters

2019-01-02 Thread Stephen De Gabrielle
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.