Skip to content

Instantly share code, notes, and snippets.

@seratch
Last active September 3, 2015 06:50
Show Gist options
  • Save seratch/3648084b512be8eeeaa8 to your computer and use it in GitHub Desktop.
Save seratch/3648084b512be8eeeaa8 to your computer and use it in GitHub Desktop.
AutoRouting idea
import skinny.micro._
import skinny.micro.contrib.AutoRouting
// @path("/articles")
class Articles extend WebApp with AutoRouting {
// curl /articles/123?withComments=false
@get @path("/:id")
def show(id: Long, withComments: Option[Boolean]): ActionResult = ???
@get @path("/:articleId/comments")
def showComments(articleId: Long): ActionResult = ???
// curl -XPOST /articles/search -d'keyword=scala'
@post def search(keyword: Option[String]): ActionResult = ???
// curl /articles/analysisResult?yyyymm=201509
@get def analysisResult(
// how to bind this?
yyyymm: Try[(Int, Int)]): ActionResult = ???
/* TODOs:
- @POST or @post (down cased naming looks more Scala-ish)
- distinguish query params and form params?
- convert CamelCase/snake_case style (key name, path name)?
- bind validation rules to each param binder?
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment