Skip to content

Improve HTTP client configuration with functional options #1

Description

@martinyonatann

Problem

The generated achievement client currently uses TransportConfig for HTTP
client configuration:

client := achievementclient.NewHTTPClientWithConfig(
    strfmt.Default,
    &achievementclient.TransportConfig{
        Host:     "demo.accelbyte.io",
        BasePath: "/api/v1",
        Schemes:  []string{"https"},
    },
)

This requires callers to construct and manage a configuration struct even when only a small number of options need to be customized.

Proposed improvement

Introduce functional options for configuring the HTTP client:

client := achievementclient.NewHTTPClient(
    strfmt.Default,
    achievementclient.WithHost("demo.accelbyte.io"),
    achievementclient.WithBasePath("/api/v1"),
    achievementclient.WithSchemes([]string{"https"}),
)

Proposed options:

  • WithHost
  • WithBasePath
  • WithSchemes
  • WithUserAgent

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions