Skip to content

Commit

Permalink
Merge pull request #61 from syumai/release-0.10.0
Browse files Browse the repository at this point in the history
Release 0.10.0
  • Loading branch information
syumai committed Apr 13, 2020
2 parents 9e62d1d + 9191026 commit 924bb22
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
33 changes: 22 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ import {
app,
get,
post,
redirect,
contentType,
} from 'https://denopkg.com/syumai/dinatra@0.9.0/mod.ts';
} from "https://denopkg.com/syumai/dinatra@0.10.0/mod.ts";

app(
get('/hello', () => 'hello'),
get('/hello/:id', ({ params }) => params.id),
get('/hello/:id/and/:name', ({ params }) => `:id is ${params.id}, :name is ${params.name}`),
get('/error', () => [500, 'an error has occured']),
get('/callName', ({ params }) => `Hi, ${params.name}!`),
post('/callName', ({ params }) => `Hi, ${params.name}!`),
get('/info', () => [
get("/hello", () => "hello"),
get("/hello/:id", ({ params }) => params.id),
get(
"/hello/:id/and/:name",
({ params }) => `:id is ${params.id}, :name is ${params.name}`,
),
get("/error", () => [500, "an error has occured"]),
get("/callName", ({ params }) => `Hi, ${params.name}!`),
post("/callName", ({ params }) => `Hi, ${params.name}!`),
get("/foo", () => redirect("/hello", 302)), // redirect from /foo to /hello
get("/info", () => [
200,
contentType('json'),
JSON.stringify({ app: 'dinatra', version: '0.0.1' }),
])
contentType("json"),
JSON.stringify({ app: "dinatra", version: "0.0.1" }),
]),
);
```

Expand Down Expand Up @@ -61,6 +66,10 @@ curl -d 'name=Tom' http://localhost:8080/callName
# status: 200
# body: Hi, Tom!

curl http://localhost:8080/foo
# status: 302
# location: /hello

curl http://localhost:8080/info
# status: 200
# content-type: application/json
Expand Down Expand Up @@ -180,7 +189,9 @@ interface HTTPResponse {
- [x] URL query params (for GET)
- [x] route params (like: `/users/:user_id/posts`)
- [x] x-www-form-urlencoded
- [x] redirect
- [x] application/json
- [ ] application/octet-stream

## Development

Expand Down
3 changes: 2 additions & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, get, post, contentType } from "../mod.ts";
import { app, get, post, redirect, contentType } from "../mod.ts";

app(
get("/hello", () => "hello"),
Expand All @@ -10,6 +10,7 @@ app(
get("/error", () => [500, "an error has occured"]),
get("/callName", ({ params }) => `Hi, ${params.name}!`),
post("/callName", ({ params }) => `Hi, ${params.name}!`),
get("/foo", () => redirect("/hello", 302)), // redirect from /foo to /hello
get("/info", () => [
200,
contentType("json"),
Expand Down

0 comments on commit 924bb22

Please sign in to comment.