Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.7.1"
".": "0.8.0"
}
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 0.8.0 (2026-05-01)

Full Changelog: [v0.7.1...v0.8.0](https://github.com/openlayer-ai/openlayer-go/compare/v0.7.1...v0.8.0)

### Features

* **go:** add default http client with timeout ([da44eaf](https://github.com/openlayer-ai/openlayer-go/commit/da44eaf95248221675f2fad295bb5d077fcff661))
* support setting headers via env ([7e985fe](https://github.com/openlayer-ai/openlayer-go/commit/7e985fe107dff7315cdc641249c35702ba922c0e))


### Chores

* avoid embedding reflect.Type for dead code elimination ([5614b9a](https://github.com/openlayer-ai/openlayer-go/commit/5614b9adad1475db7b0679e381cb4fdea7e38909))
* **internal:** more robust bootstrap script ([24a151f](https://github.com/openlayer-ai/openlayer-go/commit/24a151ff7c5d0ddc8c5cc2ed081c7b3bd6b38f23))
* **tests:** bump steady to v0.22.1 ([7489be2](https://github.com/openlayer-ai/openlayer-go/commit/7489be22b8e6e9e0a62ed9297b18a44dc6db45cc))

## 0.7.1 (2026-04-10)

Full Changelog: [v0.7.0...v0.7.1](https://github.com/openlayer-ai/openlayer-go/compare/v0.7.0...v0.7.1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openlayer-ai/openlayer-go@v0.7.1'
go get -u 'github.com/openlayer-ai/openlayer-go@v0.8.0'
```

<!-- x-release-please-end -->
Expand Down
11 changes: 10 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"slices"
"strings"

"github.com/openlayer-ai/openlayer-go/internal/requestconfig"
"github.com/openlayer-ai/openlayer-go/option"
Expand All @@ -28,13 +29,21 @@ type Client struct {
// DefaultClientOptions read from the environment (OPENLAYER_API_KEY,
// OPENLAYER_BASE_URL). This should be used to initialize new clients.
func DefaultClientOptions() []option.RequestOption {
defaults := []option.RequestOption{option.WithEnvironmentProduction()}
defaults := []option.RequestOption{option.WithHTTPClient(defaultHTTPClient()), option.WithEnvironmentProduction()}
if o, ok := os.LookupEnv("OPENLAYER_BASE_URL"); ok {
defaults = append(defaults, option.WithBaseURL(o))
}
if o, ok := os.LookupEnv("OPENLAYER_API_KEY"); ok {
defaults = append(defaults, option.WithAPIKey(o))
}
if o, ok := os.LookupEnv("OPENLAYER_CUSTOM_HEADERS"); ok {
for _, line := range strings.Split(o, "\n") {
colon := strings.Index(line, ":")
if colon >= 0 {
defaults = append(defaults, option.WithHeader(strings.TrimSpace(line[:colon]), strings.TrimSpace(line[colon+1:])))
}
}
}
return defaults
}

Expand Down
24 changes: 24 additions & 0 deletions default_http_client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

package openlayer

import (
"net/http"
"time"
)

// defaultResponseHeaderTimeout bounds the time between a fully written request
// and the server's response headers. It does not apply to the response body,
// so long-running streams are unaffected. Without this, a server that accepts
// the connection but never responds would hang the request indefinitely.
const defaultResponseHeaderTimeout = 10 * time.Minute

// defaultHTTPClient returns an [*http.Client] used when the caller does not
// supply one via [option.WithHTTPClient]. It clones [http.DefaultTransport]
// and adds a [http.Transport.ResponseHeaderTimeout] so stuck connections
// fail fast instead of compounding across retries.
func defaultHTTPClient() *http.Client {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.ResponseHeaderTimeout = defaultResponseHeaderTimeout
return &http.Client{Transport: transport}
}
4 changes: 2 additions & 2 deletions internal/apiform/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type encoderField struct {
}

type encoderEntry struct {
reflect.Type
typ reflect.Type
dateFormat string
root bool
}
Expand All @@ -59,7 +59,7 @@ func (e *encoder) marshal(value interface{}, writer *multipart.Writer) error {

func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
Type: t,
typ: t,
dateFormat: e.dateFormat,
root: e.root,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/apijson/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type decoderField struct {
}

type decoderEntry struct {
reflect.Type
typ reflect.Type
dateFormat string
root bool
}
Expand All @@ -91,7 +91,7 @@ func (d *decoderBuilder) unmarshal(raw []byte, to any) error {

func (d *decoderBuilder) typeDecoder(t reflect.Type) decoderFunc {
entry := decoderEntry{
Type: t,
typ: t,
dateFormat: d.dateFormat,
root: d.root,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/apijson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type encoderField struct {
}

type encoderEntry struct {
reflect.Type
typ reflect.Type
dateFormat string
root bool
}
Expand All @@ -63,7 +63,7 @@ func (e *encoder) marshal(value interface{}) ([]byte, error) {

func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
Type: t,
typ: t,
dateFormat: e.dateFormat,
root: e.root,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/apiquery/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type encoderField struct {
}

type encoderEntry struct {
reflect.Type
typ reflect.Type
dateFormat string
root bool
settings QuerySettings
Expand All @@ -42,7 +42,7 @@ type Pair struct {

func (e *encoder) typeEncoder(t reflect.Type) encoderFunc {
entry := encoderEntry{
Type: t,
typ: t,
dateFormat: e.dateFormat,
root: e.root,
settings: e.settings,
Expand Down
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package internal

const PackageVersion = "0.7.1" // x-release-please-version
const PackageVersion = "0.8.0" // x-release-please-version
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "${SKIP_BREW:-}" != "1" ] && [ -t 0 ]; then
brew bundle check >/dev/null 2>&1 || {
echo -n "==> Install Homebrew dependencies? (y/N): "
read -r response
Expand Down
6 changes: 3 additions & 3 deletions scripts/mock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ echo "==> Starting mock server with URL ${URL}"
# Run steady mock on the given spec
if [ "$1" == "--daemon" ]; then
# Pre-install the package so the download doesn't eat into the startup timeout
npm exec --package=@stdy/cli@0.20.2 -- steady --version
npm exec --package=@stdy/cli@0.22.1 -- steady --version

npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log &

# Wait for server to come online via health endpoint (max 30s)
echo -n "Waiting for server"
Expand All @@ -48,5 +48,5 @@ if [ "$1" == "--daemon" ]; then

echo
else
npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
npm exec --package=@stdy/cli@0.22.1 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL"
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ elif ! steady_is_running ; then
echo -e "To run the server, pass in the path or url of your OpenAPI"
echo -e "spec to the steady command:"
echo
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.22.1 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=comma --validator-form-array-format=comma --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}"
echo

exit 1
Expand Down
Loading