-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: expose url in channel interface #214
Conversation
reopening, I'm going to take over getting storacha/w3up#404 merged - @Gozala would love a review from you when you get a chance! |
channels won't always have URLs, I think, so make them optional
The HTTP channel already has a I think you just need an import { Channel as HttpChannel } from '@ucanto/transport/http'
const { channel } = connection
if (!(channel instanceof HttpChannel)) throw new Error('HTTP channel is required')
const { url } = channel
// do something with URL I assume the idea is that not all channels will be HTTP in the future... If you add the type (this PR) then you're still going to need the conditional to check for existence of the |
This fixes #344 and makes it possible to connect to staging services with w3ui. This PR obsoletes #404 per @alanshaw's suggestion in #404 (comment) based on reasoning in storacha/ucanto#214 (comment) which points out that some sort of conditional or casting is probably unavoidable here. My solution casts the channel to have an optional `url` field and looks in that field for a URL before falling back to the default `HOST`.
closing in favor of a solution to the underlying issue proposed in storacha/w3up#440 |
This fixes #344 and makes it possible to connect to staging services with w3ui. This PR obsoletes #404 per @alanshaw's suggestion in #404 (comment) based on reasoning in storacha/ucanto#214 (comment) which points out that some sort of conditional or casting is probably unavoidable here. My solution casts the channel to have an optional `url` field and looks in that field for a URL before falling back to the default `HOST`. Have tested this locally with w3ui and verified it makes it possible to connect to staging services from w3ui - huzzah!
This fixes #344 and makes it possible to connect to staging services with w3ui. This PR obsoletes #404 per @alanshaw's suggestion in #404 (comment) based on reasoning in storacha/ucanto#214 (comment) which points out that some sort of conditional or casting is probably unavoidable here. My solution casts the channel to have an optional `url` field and looks in that field for a URL before falling back to the default `HOST`. Have tested this locally with w3ui and verified it makes it possible to connect to staging services from w3ui - huzzah!
Its useful to be able to get the url from the channel directly, in situations where the connection is passed into a function or class and we want to use the connection url has the default for any other communications like WS.
Instead of input url + connection we can just ask the user for connection.
example : storacha/w3up#404