On Apr 4, 2016, at 8:15 PM, David Vanderson <david.vander...@gmail.com> wrote:
> 
> On 04/04/2016 02:08 PM, Brian Adkins wrote:
>> (routes
>>   ("/" home-page)
>>   ("/:org_shortname/product_image/:style/:filename" product-image #:verbs 
>> (get)
>>    #:name prod-image #:when (regexp-match #rx".jpg$" filename))
>>   ("/products/(*id).json" product-show #:verbs (get)))
>> 
>>  Any feedback is appreciated.
>> 
> Good start!  

Thanks :)

> One thing I liked about dispatch-rules is that it breaks the url parts up, so 
> you don't have to parse the string.  

My goal for the syntax is to make it as easy on the developer (i.e. user of the 
framework) as possible vs. being easy on me as the framework author. I expect 
the string can be parsed at compile time via a macro. I have to admit that in 
ten years of Rails development, I don't recall offhand ever having a parameter 
that wasn't an entire "node" of the URL, so my previous example of 
"/product/item-:id" may be a red herring. On the other hand, I don't see a 
reason to make that impossible. I do think I've used route globbing w/in a URL 
node, so I'd like to keep the string representation.

> If you could name them, then the part names could be racket identifiers in 
> scope, so you don't have misspelling issues in the #:when function.  

That should be able to be checked at compile time via a macro, right?

> I'm imagining that the route is essentially a match clause against a url 
> split by '/'.  Not sure if I'm making sense, but something like:

The url will split on '/', but nodes may be combined via globbing or a node may 
have a substring that's a parameter. For example:

"/products/(*id).json" e.g. /products/foo/bar/baz.json => id = 'foo/bar/baz' 

or "/product/item-:id" as mentioned above where /product/item-7 would result in 
id = '7'

> 
> (routes
>  (route ("")
>         home-page)
>  (route (org_shortname "product_image" style filename)
>         product-image
>         #:name prod-image #:methods (get put)
>         #:when (regexp-match #rx".jpg$" filename)))
> 
> Maybe there's a way to tag url parts with predicates, sort of like 
> dispatch-rules or syntax-parse, but it might obscure the url too much:
> 
> (route ((org_shortname string?)
>        "product_image"
>        (style number?)
>        (filename (lambda () (regexp-match #rx".jpg$" filename))))
>       #:name prod-image #:methods (get put))
> 

I can think of a number of ways to make this much easier on myself, but as I 
mentioned, I'm trying to maximize ease for the framework user. Now, if I 
encounter serious roadblocks while implementing this, I may need to make 
concessions :)

> Hope this helps,
> Dave
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Racket Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/racket-users/wZ07AM8SBuw/unsubscribe.
> To unsubscribe from this group and all its topics, 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.

Reply via email to