-
-
Save casualjim/1411786 to your computer and use it in GitHub Desktop.
Creating API docs for scalatra
This file contains hidden or 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
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 | |
} |
This file contains hidden or 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
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