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
2 changes: 1 addition & 1 deletion docs/docs/agents/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Counter(Agent):
async def on_request(self, request: Request) -> Response:
if request.method == "POST":
await self.increment()
return Response.from_json(self.state)
return Response.json(self.state)


class Default(WorkerEntrypoint):
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/agents/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class Default(WorkerEntrypoint):
async def fetch(self, request: Request) -> Response:
counter = await get_agent_by_name(self.env.Counter, "from-worker")
count = await counter.increment(5)
return Response.from_json({"count": count})
return Response.json({"count": count})
```

```json
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/agents/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class Notes(Agent):
if request.method == "POST":
self.sql("INSERT INTO notes (text) VALUES (?)", await request.text())
rows = self.sql("SELECT id, text FROM notes ORDER BY id")
return Response.from_json(list(rows))
return Response.json(list(rows))
```

```sh
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/agents/sub-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Inbox(Agent):
thread = await self.dynamic_agents.get(Thread, "t1")
count = await thread.add("hi")
names = [child.name for child in self.dynamic_agents.list()]
return Response.from_json({"count": count, "threads": names})
return Response.json({"count": count, "threads": names})
```

```json
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/agents/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ from workers import Request, Response
class Reports(Agent):
async def on_request(self, request: Request) -> Response:
receipt = await self.build.run({"rows": 21})
return Response.from_json({"run_id": receipt.run_id, "state": receipt.state})
return Response.json({"run_id": receipt.run_id, "state": receipt.state})
```

```json
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/containers/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ from workers import Request, Response
async def fake_weather(
request: Request, env: Any, ctx: OutboundHandlerContext
) -> Response:
return Response.from_json({"city": "Lisbon", "temp_c": 21})
return Response.json({"city": "Lisbon", "temp_c": 21})


class Sandbox(Container):
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/containers/outbound-traffic.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ hostname match takes precedence over a glob:
async def mock_payments(
request: Request, env: Any, ctx: OutboundHandlerContext
) -> Response:
return Response.from_json({"status": "succeeded"})
return Response.json({"status": "succeeded"})


async def block(request: Request, env: Any, ctx: OutboundHandlerContext) -> Response:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/containers/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class Default(WorkerEntrypoint):
result: TranscodeResult = await container.transcode(
"https://example.com/in.mp4", "720p"
)
return Response.from_json(result)
return Response.json(result)
```

## Check requests before they reach the container
Expand Down
Loading