Last active
September 3, 2015 06:50
-
-
Save seratch/3648084b512be8eeeaa8 to your computer and use it in GitHub Desktop.
AutoRouting idea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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