Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL prefix #31

Open
tredoe opened this issue Jul 2, 2010 · 2 comments
Open

URL prefix #31

tredoe opened this issue Jul 2, 2010 · 2 comments

Comments

@tredoe
Copy link

tredoe commented Jul 2, 2010

Many times you are going to use an URL prefix, like:

urlPrefix = "/wiki/"
web.Get(urlPrefix+"view/(.+)", viewHandler)
web.Post(urlPrefix+"save/(.+)", saveHandler)

so it would be helpful a function that stores that prefix and then were inserted at the string, i.e.

web.Prefix("/wiki/")
web.Get("view/(.+)", viewHandler)  // => /wiki/view/
web.Post("save/(.+)", saveHandler)  // => /wiki/save/

web.Prefix("/blog/")
web.Get("view/(.+)", viewHandler)  // => /blog/view/

// Prefix Cleaning
web.Prefix("")
web.Get("view/(.+)", viewHandler)  // => view/
@hoisie
Copy link
Owner

hoisie commented Oct 19, 2010

This is basically supporting RESTful services, which is something I'm interested in. It would be nice to have a web.Rest("/user", class), and that class could implement methods like create, save, update, delete, etc...

@billinghamj
Copy link

Quite often, that's implemented as something like web.Resource

I think a wrapper for doing prefixing could be useful though. Like:

web.Area("/wiki", func () {
  web.Get("/view", blah)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants