Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make spin_sdk.http.IncomingHandler optional #111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dicej
Copy link
Collaborator

@dicej dicej commented Jun 26, 2024

When building a component intended for composition with other components, it may make sense to target the spin-imports world defined in the src/spin_sdk/wit/spin.wit file in this repo. However, that currently won't work because spin_sdk.http unconditionally imports spin_sdk.wit.exports, which won't exist when targeting spin-imports.

The solution is to catch the ImportError if importing the exports submodule (or its IncomingHandler class) fails and just skip defining spin_sdk.http.IncomingHandler when that happens.

Fixes #110

When building a component intended for composition with other components, it may
make sense to target the `spin-imports` world defined in the
`src/spin_sdk/wit/spin.wit` file in this repo.  However, that currently won't
work because `spin_sdk.http` unconditionally imports `spin_sdk.wit.exports`,
which won't exist when targeting `spin-imports`.

The solution is to catch the `ImportError` if importing the `exports` submodule
(or its `IncomingHandler` class) fails and just skip defining
`spin_sdk.http.IncomingHandler` when that happens.

Fixes #110

Signed-off-by: Joel Dice <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support targeting the spin-imports world
2 participants