Skip to content

Instantly share code, notes, and snippets.

@urcoilbisurco
Last active May 14, 2020 08:39
Show Gist options
  • Save urcoilbisurco/ee424f2664ff0768bfcfab99e5d6bd61 to your computer and use it in GitHub Desktop.
Save urcoilbisurco/ee424f2664ff0768bfcfab99e5d6bd61 to your computer and use it in GitHub Desktop.
import {
app,
get,
post,
redirect,
contentType,
} from "https://denopkg.com/syumai/[email protected]/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("/foo", () => redirect("/hello", 302)), // redirect from /foo to /hello
get("/info", () => [
200,
contentType("json"),
JSON.stringify({ app: "dinatra", version: "0.0.1" }),
]),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment