Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Key features:
- **Simple** — define HTTP requests as decorated async functions, no boilerplate.
- **Typed** — full type annotations throughout; validate responses with <a href="https://docs.pydantic.dev/" target="_blank">Pydantic</a> models.
- **Logged** — colorful, structured request/response logs with timing, built-in.
- **Complete** — GET, POST, PUT, PATCH, DELETE, and GraphQL out of the box.
- **Complete** — GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, and GraphQL out of the box.
- **Extensible** — middleware, dependency injection, routers, lifespan hooks.
- **Interactive** — built-in Swagger UI via `app.web_run()` to browse and execute requests in the browser.
- **HTTP/2** — optional HTTP/2 support, with automatic fallback to HTTP/1.1.
Expand Down Expand Up @@ -220,11 +220,26 @@ async def put_data(resp: Response) -> dict:
return resp.json()


@app.patch(url="https://httpbin.org/patch")
async def patch_data(resp: Response) -> dict:
return resp.json()


@app.delete(url="https://httpbin.org/delete")
async def delete_data(resp: Response) -> int:
return resp.status_code


@app.head(url="https://httpbin.org/get")
async def head_data(resp: Response) -> int:
return resp.status


@app.options(url="https://httpbin.org/get")
async def options_data(resp: Response) -> dict:
return {"allow": resp.headers.get("allow", "")}


if __name__ == "__main__":
app.run()
```
Expand Down
33 changes: 31 additions & 2 deletions docs/en/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ app = FastHTTP(
| `put_request` | `dict` | `{}` | PUT settings |
| `patch_request` | `dict` | `{}` | PATCH settings |
| `delete_request` | `dict` | `{}` | DELETE settings |
| `head_request` | `dict` | `{}` | HEAD settings |
| `options_request` | `dict` | `{}` | OPTIONS settings |
| `middleware` | `list` | `[]` | Middleware list |
| `security` | `bool` | `True` | Enable built-in security |
| `lifespan` | `Callable` | `None` | Context manager for startup/shutdown |
Expand Down Expand Up @@ -189,7 +191,34 @@ async def lifespan(app):
response_model: type = None,
request_model: type = None,
responses: dict = None,
delete_request: dict = None,
)
```

### @app.head()

```python
@app.head(
url: str,
params: dict = None,
tags: list = [],
dependencies: list = [],
response_model: type = None,
request_model: type = None,
responses: dict = None,
)
```

### @app.options()

```python
@app.options(
url: str,
params: dict = None,
tags: list = [],
dependencies: list = [],
response_model: type = None,
request_model: type = None,
responses: dict = None,
)
```

Expand Down Expand Up @@ -481,7 +510,7 @@ The Route object represents a registered HTTP request. It contains all informati

| Attribute | Type | Description |
|-----------|------|-------------|
| `method` | `str` | HTTP method (GET, POST, PUT, PATCH, DELETE) |
| `method` | `str` | HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS) |
| `url` | `str` | Full URL of the request |
| `params` | `dict` | Query parameters |
| `json` | `dict` | JSON body sent with request |
Expand Down
2 changes: 1 addition & 1 deletion docs/en/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Both functions work the same way — the system automatically detects the functi
The `route` object contains all information about the request:

```python
route.method # HTTP method: "GET", "POST", "PUT", "PATCH", "DELETE"
route.method # HTTP method: "GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"
route.url # Full request URL
route.params # Query parameters (dictionary)
route.json # JSON request body (dictionary)
Expand Down
Loading
Loading