Skip to content

Instantly share code, notes, and snippets.

@casualjim
Forked from robb1e/base.scala
Created November 30, 2011 23:19
Show Gist options
  • Save casualjim/1411786 to your computer and use it in GitHub Desktop.
Save casualjim/1411786 to your computer and use it in GitHub Desktop.
Creating API docs for scalatra
class HttpMethod
object HttpPostMethod extends HttpMethod { override def toString = "POST" }
object HttpGetMethod extends HttpMethod { override def toString = "GET" }
object HttpDeleteMethod extends HttpMethod { override def toString = "DELETE" }
object HttpPutMethod extends HttpMethod { override def toString = "PUT" }
trait Param {
def name: String
def description: String
}
trait Endpoint {
def slug: String
def path: String
def stringFormat: String
lazy val requiredParams: List[Param] = List()
lazy val optionalParams: List[Param] = List()
def description: String
def method: HttpMethod
}
object ApiResource extends Endpoint {
val slug = "/resource"
...
}
implicit def endpoint2RouteMatcher(endpoint: Endpoint): RouteMatcher = new SinatraRouteMatcher(endpoint.path, requestPath)
get(ApiAction) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment