Skip to content

Commit

Permalink
docs: refactor API endpoint to use 'documents' route for uploading do…
Browse files Browse the repository at this point in the history
…cuments
  • Loading branch information
glaucia86 committed Apr 3, 2024
1 parent a784869 commit 22af4cb
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions docs/tutorial/03-session.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ export async function uploadDocuments(request: HttpRequest, context: InvocationC
return serviceUnavailable(new Error('Service temporarily unavailable. Please try again later.'));
}
}

app.http('post-documents', {
route: 'documents',
methods: ['POST'],
authLevel: 'anonymous',
handler: uploadDocuments,
});
```

Let's understand what we did here:
Expand Down Expand Up @@ -113,6 +120,13 @@ export async function uploadDocuments(request: HttpRequest, context: InvocationC
return serviceUnavailable(new Error('Service temporarily unavailable. Please try again later.'));
}
}

app.http('post-documents', {
route: 'documents',
methods: ['POST'],
authLevel: 'anonymous',
handler: uploadDocuments,
});
```

Let's understand what we did here:
Expand Down Expand Up @@ -206,8 +220,8 @@ export async function uploadDocuments(request: HttpRequest, context: InvocationC
}

app.http('post-documents', {
route: 'upload',
methods: ['GET', 'POST'],
route: 'documents',
methods: ['POST'],
authLevel: 'anonymous',
handler: uploadDocuments,
});
Expand Down Expand Up @@ -250,10 +264,8 @@ Before we test the `upload` API, let's configure the `api.http` file for this re
- `api/http`

```http
(... here are the previous requests)
### Upload PDF Document
POST {{api_host}}/api/upload
POST {{api_host}}/api/documents
Accept: */*
Content-Type: multipart/form-data; boundary=Boundary
Expand Down

0 comments on commit 22af4cb

Please sign in to comment.