Skip to content

Commit

Permalink
example of sendfile
Browse files Browse the repository at this point in the history
  • Loading branch information
goshacmd committed Aug 23, 2012
1 parent cb873d9 commit 20a8d34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -4,10 +4,12 @@ A simple [dynamo](https://github.com/josevalim/dynamo) application.

It is an example of simple Dynamo application, which:

* handles GET requests
* uses callbacks
* sets custom headers
* uses parametrized routes
* sets custom status code
* sends files

## API

Expand All @@ -22,6 +24,10 @@ Responds with blank JSON object.
Responds with JSON object containing `version` key with value of
`DynamoDemo.version`.

### GET /readme

Responds with plain text contents of this README.md file.

### GET /hello

Responds with JSON greeting the world.
Expand Down
5 changes: 5 additions & 0 deletions lib/dynamo_demo/app.ex
Expand Up @@ -16,6 +16,11 @@ defmodule DynamoDemo.App do
conn.resp 200, "{\"version\":\"#{DynamoDemo.version}\"}\n"
end

get "/readme" do
conn = conn.set_resp_header "Content-Type", "text/plain"
conn.sendfile "README.md"
end

get "/hello" do
conn.resp 200, "{\"hello\":\"world\"}\n"
end
Expand Down

0 comments on commit 20a8d34

Please sign in to comment.