Skip to content

HttpConnectionOptions missing public initializer blocks external usage #77

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

Closed
yannisalexiou opened this issue May 2, 2025 · 2 comments

Comments

@yannisalexiou
Copy link
Contributor

🐛 Missing Public Initializer in HttpConnectionOptions Prevents External Customization

Summary

HttpConnectionOptions is a public struct with many configurable public properties such as accessTokenFactory, but it lacks a public init(), making it impossible to initialize from outside the module.

Problem

Although the library exposes HubConnectionBuilder.withUrl(url:options:), consumers cannot use this method effectively because they cannot instantiate a HttpConnectionOptions object.

For example, the following code is not possible due to lack of a public initializer:

var options = HttpConnectionOptions() // ⛔️ Error: init is inaccessible
options.accessTokenFactory = { return "my-token" } 

Image

Proposed Fix

Expose a public init() inside HttpConnectionOptions to allow consumers to create and configure the struct from their own code. This was already mentioned here #65 and as issue here

PR

This issue is being addressed in the following pull request: #76

Benefit

This change would unblock valid usage patterns for setting authentication and other details when building SignalR connections using the Swift client SDK.

@bjqian
Copy link
Collaborator

bjqian commented May 6, 2025

A new version with the fix has been released: https://github.com/dotnet/signalr-client-swift/releases/tag/v1.0.0-preview.4

@bjqian bjqian closed this as completed May 6, 2025
@bingtice
Copy link

bingtice commented May 6, 2025

I have added SignalRClient to the Swift PackageList
I believe the first release version will come soon 👍👍👍

https://swiftpackageindex.com/dotnet/signalr-client-swift

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

No branches or pull requests

3 participants