You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Define one or more steps that optionally return state.
@@ -188,13 +223,18 @@ We have a very basic Workflow definition, but now need to provide a way to call
188
223
Return to the `src/index.ts` file we created in the previous step and add a `fetch` handler that _binds_ to our Workflow. This binding allows us to create new Workflow instances, fetch the status of an existing Workflow, pause and/or terminate a Workflow.
189
224
190
225
```ts title="src/index.ts"
191
-
// This can be in the same file as our Workflow definition
226
+
// This is in the same file as your Workflow definition
let id =newURL(req.url).searchParams.get('instanceId');
230
+
let url =newURL(req.url);
231
+
232
+
if (url.pathname.startsWith('/favicon')) {
233
+
returnResponse.json({}, { status: 404 });
234
+
}
196
235
197
236
// Get the status of an existing instance, if provided
237
+
let id =url.searchParams.get('instanceId');
198
238
if (id) {
199
239
let instance =awaitenv.MY_WORKFLOW.get(id);
200
240
returnResponse.json({
@@ -210,7 +250,6 @@ export default {
210
250
});
211
251
},
212
252
};
213
-
;
214
253
```
215
254
216
255
The code here exposes a HTTP endpoint that generates a random ID and runs the Workflow, returning the ID and the Workflow status. It also accepts an optional `instanceId` query parameter that retrieves the status of a Workflow instance by its ID.
0 commit comments