-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add http-gateway library and cloudflare gateway example project #42
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
base: main
Are you sure you want to change the base?
Conversation
@@ -5,6 +5,7 @@ dist/ | |||
pocket-ic | |||
.env | |||
Cargo.lock | |||
.wrangler |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This folder is generated by Cloudflare's wrangler CLI
README.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated cleanup, removing deprecated projects and replacing with newer ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next few files belong to the Cloudflare worker example project that leverages the JS library to run an HTTP Gateway. Docs and implementation are still a little rough around the edges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main logic for the Cloudlfare worker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next few files belong to a library that exports a simple wrapper around an actor built with pre-generated types that correspond to the expected interface for a canister that the HTTP Gateway will interact with. There is also some simple mapping between more idiomatic TypeScript types and those generated by Candid.
packages/http-gateway-js/LICENSE
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The next few files belong to the actual HTTP Gateway JavaScript library.
@@ -0,0 +1,40 @@ | |||
import { HttpGatewayClient } from '@dfinity/http-gateway'; | |||
import { HttpAgent } from '@dfinity/agent'; | |||
import RESPONSE_VERIFICATION_WASM from '@dfinity/response-verification/dist/web/web_bg.wasm'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had issues with loading the WASM when the HTTP Gateway library did it internally. This should work fine in other environments, but Cloudflare doesn't like it for some reason. Loading it explicitly inside the worker and passing it as a parameter works well, although I really don't like it.
This PR includes a very minimal version of a JavaScript based HTTP Gateway library and an example project that shows how to use this library to run an HTTP Gateway on Cloudflare. This is still experimental and a PoC at this point.