Skip to content

Instantly share code, notes, and snippets.

@jdegoes
Created February 4, 2014 17:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdegoes/8808245 to your computer and use it in GitHub Desktop.
Save jdegoes/8808245 to your computer and use it in GitHub Desktop.
A preview of the RedEyes web framework
/*
* RedEyes generates rich descriptions of the API, as well as valid examples for
* all parameters (in this case, example header, query parameter, and content).
*
* The API can also be used to generate client libraries in a variety of languages.
*
* Service handlers are strongly-typed (e.g. retrieveEmployees expects an integer
* and a ModelDesc). Any errors in using the API automatically generate rich
* descriptions on what was expected.
*/
val headers = contentType("application/json") <|> contentType("text/json")
val api = Handlers.retrieveEmployees <| GET >*> path("/employees/") >*> headers >*> queryInt("limit") <*> (contentText[ModelDesc] ^? "A filter on the employees to retrieve")
val documentation = describe(api).toMarkdown
val server = NioServerCompiler.compile(api)
server.run(config).unsafePerformIO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment