# Routing

Handle different request types in a single function to create efficient APIs.

## Overview

Edge Functions support **`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `OPTIONS`**. This means you can build complete REST APIs in a single function:

```tsx
Deno.serve(async (req) => {
  const { method, url } = req
  const { pathname } = new URL(url)

  // Route based on method and path
  if (method === 'GET' && pathname === '/users') {
    return getAllUsers()
  } else if (method === 'POST' && pathname === '/users') {
    return createUser(req)
  }

  return new Response('Not found', { status: 404 })
})
```

Edge Functions allow you to build APIs without needing separate functions for each endpoint. This reduces cold starts and simplifies deployment while keeping your code organized.

HTML content is not supported. `GET` requests that return `text/html` will be rewritten to `text/plain`. Edge Functions are designed for APIs and data processing, not serving web pages. Use Supabase for your backend API and your favorite frontend framework for HTML.

---

## Example

Here's a full example of a RESTful API built with Edge Functions.