Add server URL normalization for flexible WithServerURL input#81
Draft
chris-freeman-glean wants to merge 1 commit intomainfrom
Draft
Add server URL normalization for flexible WithServerURL input#81chris-freeman-glean wants to merge 1 commit intomainfrom
chris-freeman-glean wants to merge 1 commit intomainfrom
Conversation
Prepend https:// when no scheme is provided and strip trailing slashes from the base URL during SDK initialization.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds server URL normalization so users can pass schemeless URLs (e.g.,
"mycompany-be.glean.com") toWithServerURL()when constructing the SDK client. This is part of promotingWithServerURL()as the primary configuration option, replacingWithInstance()in all documentation and examples.Go-specific implementation
Uses Speakeasy's SDKInit hook mechanism (
internal/hooks/server_url_normalizer.go). The hook receives the raw server URL string during SDK initialization and normalizes it before it's used for requests. This is the standard approach — the Go SDK passes raw strings to the SDKInit hook.The hook is registered in
registration.goas the first hook to run during initialization.Normalization rules
https://http://preserved (for localhost/dev)https://preservedUser-facing API
Backwards compatibility
The
WithInstance()option continues to work unchanged. No breaking changes.Test plan