The URL is part of the request structure that the servlet receives as an argument. You can get the url by calling request-uri , then you can look at it to do whatever you want. The request also includes an HTTP method, headers, etc.
But it is rather low level. The best solution is to use dispatch-rules to determine the mapping of URL patterns to handler functions. Here is an example from the docs:
(define-values (blog-dispatch blog-url) (dispatch-rules [("") list-posts] [("posts" (string-arg)) review-post] [("archive" (integer-arg) (integer-arg)) review-archive] [else list-posts]))
Make the main blog-dispatch servlet handler. The URL http://yoursite.com/ will be processed by a call (list-posts req) , where req is the request structure. The URL http://yoursite.com/posts/a-funny-story will be processed by a call (review-post req "a-funny-story") . And so on.
source share