Skip to content

Commit be53af4

Browse files
Merge pull request #82 from OneBusAway/release-please--branches--main--changes--next
release: 1.0.0
2 parents e789def + 23ba618 commit be53af4

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.24"
2+
".": "1.0.0"
33
}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## 1.0.0 (2025-05-17)
4+
5+
Full Changelog: [v0.1.0-alpha.24...v1.0.0](https://github.com/OneBusAway/go-sdk/compare/v0.1.0-alpha.24...v1.0.0)
6+
7+
### Chores
8+
9+
* **internal:** codegen related update ([681c135](https://github.com/OneBusAway/go-sdk/commit/681c135a5d30db41ce1f3abf8968e36314161d4b))
10+
311
## 0.1.0-alpha.24 (2025-04-30)
412

513
Full Changelog: [v0.1.0-alpha.23...v0.1.0-alpha.24](https://github.com/OneBusAway/go-sdk/compare/v0.1.0-alpha.23...v0.1.0-alpha.24)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Or to pin the version:
2424
<!-- x-release-please-start-version -->
2525

2626
```sh
27-
go get -u 'github.com/OneBusAway/go-sdk@v0.1.0-alpha.24'
27+
go get -u 'github.com/OneBusAway/go-sdk@v1.0.0'
2828
```
2929

3030
<!-- x-release-please-end -->

internal/requestconfig/requestconfig.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ type RequestConfig struct {
208208
Context context.Context
209209
Request *http.Request
210210
BaseURL *url.URL
211+
// DefaultBaseURL will be used if BaseURL is not explicitly overridden using
212+
// WithBaseURL.
213+
DefaultBaseURL *url.URL
211214
CustomHTTPDoer HTTPDoer
212215
HTTPClient *http.Client
213216
Middlewares []middleware
@@ -374,7 +377,11 @@ func retryDelay(res *http.Response, retryCount int) time.Duration {
374377

375378
func (cfg *RequestConfig) Execute() (err error) {
376379
if cfg.BaseURL == nil {
377-
return fmt.Errorf("requestconfig: base url is not set")
380+
if cfg.DefaultBaseURL != nil {
381+
cfg.BaseURL = cfg.DefaultBaseURL
382+
} else {
383+
return fmt.Errorf("requestconfig: base url is not set")
384+
}
378385
}
379386

380387
cfg.Request.URL, err = cfg.BaseURL.Parse(strings.TrimLeft(cfg.Request.URL.String(), "/"))
@@ -508,6 +515,7 @@ func (cfg *RequestConfig) Execute() (err error) {
508515
}
509516

510517
contents, err := io.ReadAll(res.Body)
518+
res.Body.Close()
511519
if err != nil {
512520
return fmt.Errorf("error reading response body: %w", err)
513521
}
@@ -607,3 +615,17 @@ func PreRequestOptions(opts ...RequestOption) (RequestConfig, error) {
607615
}
608616
return cfg, nil
609617
}
618+
619+
// WithDefaultBaseURL returns a RequestOption that sets the client's default Base URL.
620+
// This is always overridden by setting a base URL with WithBaseURL.
621+
// WithBaseURL should be used instead of WithDefaultBaseURL except in internal code.
622+
func WithDefaultBaseURL(baseURL string) RequestOption {
623+
u, err := url.Parse(baseURL)
624+
return RequestOptionFunc(func(r *RequestConfig) error {
625+
if err != nil {
626+
return err
627+
}
628+
r.DefaultBaseURL = u
629+
return nil
630+
})
631+
}

internal/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
package internal
44

5-
const PackageVersion = "0.1.0-alpha.24" // x-release-please-version
5+
const PackageVersion = "1.0.0" // x-release-please-version

option/requestoption.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ func WithJSONSet(key string, value interface{}) RequestOption {
182182
if err != nil {
183183
return err
184184
}
185-
return nil
186185
} else {
187186
return fmt.Errorf("cannot use WithJSONSet on a body that is not serialized as *bytes.Buffer")
188187
}
@@ -263,7 +262,7 @@ func WithRequestTimeout(dur time.Duration) RequestOption {
263262
// environment to be the "production" environment. An environment specifies which base URL
264263
// to use by default.
265264
func WithEnvironmentProduction() RequestOption {
266-
return WithBaseURL("https://api.pugetsound.onebusaway.org/")
265+
return requestconfig.WithDefaultBaseURL("https://api.pugetsound.onebusaway.org/")
267266
}
268267

269268
// WithAPIKey returns a RequestOption that sets the client setting "api_key".

0 commit comments

Comments
 (0)