Skip to content

Support requests to wasm modules in http processor#2144

Merged
siddhantk232 merged 5 commits intomainfrom
fix/http-wasm
Jun 11, 2025
Merged

Support requests to wasm modules in http processor#2144
siddhantk232 merged 5 commits intomainfrom
fix/http-wasm

Conversation

@siddhantk232
Copy link
Copy Markdown
Contributor

@siddhantk232 siddhantk232 commented Jun 11, 2025

Handle wasm modules in mountpoints of apps

TLDR: the following code works now:

;; FASTN.ftd
-- import: fastn

-- fastn.package: test

-- fastn.dependency: lets-teach.fifthtry.site

-- fastn.app: Lets Teach App
mount-point: /teach/
package: lets-teach.fifthtry.site
;; index.ftd
-- import: fastn/processors as pr

-- some-record page-data:
$processor$: pr.http
method: post
url: /teach/backend/hello/

/teach/backend/hello/ maps to a "hello" handler defined in the backend.wasm module which is present at lets-teach.fifthtry.site/backend.wasm.

Implementation details:

We check if the url is part of a mounted app in the current package. If
it is, then we try to create a wasm+proxy:// url for implicit wasm
modules present in the app's directory. If the implicit wasm module does
not exists, we simply bail by creating a full url (prefixed with
http/https) and let the fastn server logic handle it when the http processors
calls the full url.

Handle package local relative urls

This is useful in situations like the following:

;; index.ftd
-- some-record-name d:
$processor$: processors.http
url: /local/
;; local.ftd

-- ftd.json
id: 1
name: Someone

Instead of returning an error in case of no resolution of the url. We
simply return the full url (path prefixed with scheme+host) in hopes
that fastn server logic will handle it.

The resolved will convert url /local/ -> http://127.0.0.1:800/local/
(depends on running env) which is where the http request from the
processor will be sent and fastn server will realise that it's a local
file and will return the correct json response.

NOTE: The http processor enhancements don't work with fastn build. Another PR should at least add a better error message when the processors fails and should show hints (using full urls would make it work with fastn build) to fix it.

fix: Wrong filename in the step to extract changelog

This will not let the CI generate the "What's Changed" section.

We check if the url is part of a mounted app in the current package. If
it is, then we try to create a wasm+proxy:// url for implicit wasm
modules present in the app's directory. If the implicit wasm module does
**not** exists, we simply bail by creating a full url (prefixed with
http) and let the fastn server logic handle it when the http processors
calls the full url.
Instead of returning an error in case of no resolution of the url. We
simply return the full url (path prefixed with scheme+host) in hopes
that fastn server logic will handle it.

This is useful in situations like the following:

```ftd
;; index.ftd
-- some-record-name d:
$processor$: processors.http
url: /local/
```

```ftd
;; local.ftd

-- ftd.json
id: 1
name: Someone
```

The resolved will convert url `/local/` -> `http://127.0.0.1:800/local/`
(depends on running env) which is where the http request from the
processor will be sent and fastn server will realise that it's a local
file and will return the correct json response.
@siddhantk232 siddhantk232 requested a review from amitu June 11, 2025 06:09
@amitu
Copy link
Copy Markdown
Contributor

amitu commented Jun 11, 2025

Nice touch on the /ftd-file/ stuff!

@siddhantk232 siddhantk232 merged commit 8aa6699 into main Jun 11, 2025
1 check passed
@siddhantk232 siddhantk232 deleted the fix/http-wasm branch June 11, 2025 06:21
@amitu
Copy link
Copy Markdown
Contributor

amitu commented Jun 11, 2025

It works with lets-teach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants