mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-02 20:40:52 +08:00
Fixed: #607
refactor(config): re-export internal configuration types for SDK consumers
This commit is contained in:
@@ -23,13 +23,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
|
||||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy"
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy"
|
||||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||||
clipexec "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
|
clipexec "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/logging"
|
||||||
sdktr "github.com/router-for-me/CLIProxyAPI/v6/sdk/translator"
|
sdktr "github.com/router-for-me/CLIProxyAPI/v6/sdk/translator"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
@@ -21,7 +20,7 @@ const DefaultPanelGitHubRepository = "https://github.com/router-for-me/Cli-Proxy
|
|||||||
|
|
||||||
// Config represents the application's configuration, loaded from a YAML file.
|
// Config represents the application's configuration, loaded from a YAML file.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
config.SDKConfig `yaml:",inline"`
|
SDKConfig `yaml:",inline"`
|
||||||
// Host is the network host/interface on which the API server will bind.
|
// Host is the network host/interface on which the API server will bind.
|
||||||
// Default is empty ("") to bind all interfaces (IPv4 + IPv6). Use "127.0.0.1" or "localhost" for local-only access.
|
// Default is empty ("") to bind all interfaces (IPv4 + IPv6). Use "127.0.0.1" or "localhost" for local-only access.
|
||||||
Host string `yaml:"host" json:"-"`
|
Host string `yaml:"host" json:"-"`
|
||||||
@@ -692,7 +691,7 @@ func sanitizeConfigForPersist(cfg *Config) *Config {
|
|||||||
}
|
}
|
||||||
clone := *cfg
|
clone := *cfg
|
||||||
clone.SDKConfig = cfg.SDKConfig
|
clone.SDKConfig = cfg.SDKConfig
|
||||||
clone.SDKConfig.Access = config.AccessConfig{}
|
clone.SDKConfig.Access = AccessConfig{}
|
||||||
return &clone
|
return &clone
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
87
internal/config/sdk_config.go
Normal file
87
internal/config/sdk_config.go
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
// Package config provides configuration management for the CLI Proxy API server.
|
||||||
|
// It handles loading and parsing YAML configuration files, and provides structured
|
||||||
|
// access to application settings including server port, authentication directory,
|
||||||
|
// debug settings, proxy configuration, and API keys.
|
||||||
|
package config
|
||||||
|
|
||||||
|
// SDKConfig represents the application's configuration, loaded from a YAML file.
|
||||||
|
type SDKConfig struct {
|
||||||
|
// ProxyURL is the URL of an optional proxy server to use for outbound requests.
|
||||||
|
ProxyURL string `yaml:"proxy-url" json:"proxy-url"`
|
||||||
|
|
||||||
|
// ForceModelPrefix requires explicit model prefixes (e.g., "teamA/gemini-3-pro-preview")
|
||||||
|
// to target prefixed credentials. When false, unprefixed model requests may use prefixed
|
||||||
|
// credentials as well.
|
||||||
|
ForceModelPrefix bool `yaml:"force-model-prefix" json:"force-model-prefix"`
|
||||||
|
|
||||||
|
// RequestLog enables or disables detailed request logging functionality.
|
||||||
|
RequestLog bool `yaml:"request-log" json:"request-log"`
|
||||||
|
|
||||||
|
// APIKeys is a list of keys for authenticating clients to this proxy server.
|
||||||
|
APIKeys []string `yaml:"api-keys" json:"api-keys"`
|
||||||
|
|
||||||
|
// Access holds request authentication provider configuration.
|
||||||
|
Access AccessConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessConfig groups request authentication providers.
|
||||||
|
type AccessConfig struct {
|
||||||
|
// Providers lists configured authentication providers.
|
||||||
|
Providers []AccessProvider `yaml:"providers,omitempty" json:"providers,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AccessProvider describes a request authentication provider entry.
|
||||||
|
type AccessProvider struct {
|
||||||
|
// Name is the instance identifier for the provider.
|
||||||
|
Name string `yaml:"name" json:"name"`
|
||||||
|
|
||||||
|
// Type selects the provider implementation registered via the SDK.
|
||||||
|
Type string `yaml:"type" json:"type"`
|
||||||
|
|
||||||
|
// SDK optionally names a third-party SDK module providing this provider.
|
||||||
|
SDK string `yaml:"sdk,omitempty" json:"sdk,omitempty"`
|
||||||
|
|
||||||
|
// APIKeys lists inline keys for providers that require them.
|
||||||
|
APIKeys []string `yaml:"api-keys,omitempty" json:"api-keys,omitempty"`
|
||||||
|
|
||||||
|
// Config passes provider-specific options to the implementation.
|
||||||
|
Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
// AccessProviderTypeConfigAPIKey is the built-in provider validating inline API keys.
|
||||||
|
AccessProviderTypeConfigAPIKey = "config-api-key"
|
||||||
|
|
||||||
|
// DefaultAccessProviderName is applied when no provider name is supplied.
|
||||||
|
DefaultAccessProviderName = "config-inline"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConfigAPIKeyProvider returns the first inline API key provider if present.
|
||||||
|
func (c *SDKConfig) ConfigAPIKeyProvider() *AccessProvider {
|
||||||
|
if c == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for i := range c.Access.Providers {
|
||||||
|
if c.Access.Providers[i].Type == AccessProviderTypeConfigAPIKey {
|
||||||
|
if c.Access.Providers[i].Name == "" {
|
||||||
|
c.Access.Providers[i].Name = DefaultAccessProviderName
|
||||||
|
}
|
||||||
|
return &c.Access.Providers[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeInlineAPIKeyProvider constructs an inline API key provider configuration.
|
||||||
|
// It returns nil when no keys are supplied.
|
||||||
|
func MakeInlineAPIKeyProvider(keys []string) *AccessProvider {
|
||||||
|
if len(keys) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
provider := &AccessProvider{
|
||||||
|
Name: DefaultAccessProviderName,
|
||||||
|
Type: AccessProviderTypeConfigAPIKey,
|
||||||
|
APIKeys: append([]string(nil), keys...),
|
||||||
|
}
|
||||||
|
return provider
|
||||||
|
}
|
||||||
46
sdk/api/options.go
Normal file
46
sdk/api/options.go
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// Package api exposes server option helpers for embedding CLIProxyAPI.
|
||||||
|
//
|
||||||
|
// It wraps internal server option types so external projects can configure the embedded
|
||||||
|
// HTTP server without importing internal packages.
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
internalapi "github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/logging"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServerOption customises HTTP server construction.
|
||||||
|
type ServerOption = internalapi.ServerOption
|
||||||
|
|
||||||
|
// WithMiddleware appends additional Gin middleware during server construction.
|
||||||
|
func WithMiddleware(mw ...gin.HandlerFunc) ServerOption { return internalapi.WithMiddleware(mw...) }
|
||||||
|
|
||||||
|
// WithEngineConfigurator allows callers to mutate the Gin engine prior to middleware setup.
|
||||||
|
func WithEngineConfigurator(fn func(*gin.Engine)) ServerOption {
|
||||||
|
return internalapi.WithEngineConfigurator(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithRouterConfigurator appends a callback after default routes are registered.
|
||||||
|
func WithRouterConfigurator(fn func(*gin.Engine, *handlers.BaseAPIHandler, *config.Config)) ServerOption {
|
||||||
|
return internalapi.WithRouterConfigurator(fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithLocalManagementPassword stores a runtime-only management password accepted for localhost requests.
|
||||||
|
func WithLocalManagementPassword(password string) ServerOption {
|
||||||
|
return internalapi.WithLocalManagementPassword(password)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithKeepAliveEndpoint enables a keep-alive endpoint with the provided timeout and callback.
|
||||||
|
func WithKeepAliveEndpoint(timeout time.Duration, onTimeout func()) ServerOption {
|
||||||
|
return internalapi.WithKeepAliveEndpoint(timeout, onTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithRequestLoggerFactory customises request logger creation.
|
||||||
|
func WithRequestLoggerFactory(factory func(*config.Config, string) logging.RequestLogger) ServerOption {
|
||||||
|
return internalapi.WithRequestLoggerFactory(factory)
|
||||||
|
}
|
||||||
@@ -7,10 +7,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
sdkaccess "github.com/router-for-me/CLIProxyAPI/v6/sdk/access"
|
sdkaccess "github.com/router-for-me/CLIProxyAPI/v6/sdk/access"
|
||||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Builder constructs a Service instance with customizable providers.
|
// Builder constructs a Service instance with customizable providers.
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package cliproxy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewFileTokenClientProvider returns the default token-backed client loader.
|
// NewFileTokenClientProvider returns the default token-backed client loader.
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/api"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/registry"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/registry"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/runtime/executor"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/runtime/executor"
|
||||||
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/usage"
|
_ "github.com/router-for-me/CLIProxyAPI/v6/internal/usage"
|
||||||
@@ -23,6 +22,7 @@ import (
|
|||||||
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
sdkAuth "github.com/router-for-me/CLIProxyAPI/v6/sdk/auth"
|
||||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/usage"
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/usage"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ package cliproxy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
||||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TokenClientProvider loads clients backed by stored authentication tokens.
|
// TokenClientProvider loads clients backed by stored authentication tokens.
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package cliproxy
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
|
||||||
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/watcher"
|
||||||
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
coreauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth"
|
||||||
|
"github.com/router-for-me/CLIProxyAPI/v6/sdk/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func defaultWatcherFactory(configPath, authDir string, reload func(*config.Config)) (*WatcherWrapper, error) {
|
func defaultWatcherFactory(configPath, authDir string, reload func(*config.Config)) (*WatcherWrapper, error) {
|
||||||
|
|||||||
@@ -1,87 +1,59 @@
|
|||||||
// Package config provides configuration management for the CLI Proxy API server.
|
// Package config provides the public SDK configuration API.
|
||||||
// It handles loading and parsing YAML configuration files, and provides structured
|
//
|
||||||
// access to application settings including server port, authentication directory,
|
// It re-exports the server configuration types and helpers so external projects can
|
||||||
// debug settings, proxy configuration, and API keys.
|
// embed CLIProxyAPI without importing internal packages.
|
||||||
package config
|
package config
|
||||||
|
|
||||||
// SDKConfig represents the application's configuration, loaded from a YAML file.
|
import internalconfig "github.com/router-for-me/CLIProxyAPI/v6/internal/config"
|
||||||
type SDKConfig struct {
|
|
||||||
// ProxyURL is the URL of an optional proxy server to use for outbound requests.
|
|
||||||
ProxyURL string `yaml:"proxy-url" json:"proxy-url"`
|
|
||||||
|
|
||||||
// ForceModelPrefix requires explicit model prefixes (e.g., "teamA/gemini-3-pro-preview")
|
type SDKConfig = internalconfig.SDKConfig
|
||||||
// to target prefixed credentials. When false, unprefixed model requests may use prefixed
|
type AccessConfig = internalconfig.AccessConfig
|
||||||
// credentials as well.
|
type AccessProvider = internalconfig.AccessProvider
|
||||||
ForceModelPrefix bool `yaml:"force-model-prefix" json:"force-model-prefix"`
|
|
||||||
|
|
||||||
// RequestLog enables or disables detailed request logging functionality.
|
type Config = internalconfig.Config
|
||||||
RequestLog bool `yaml:"request-log" json:"request-log"`
|
|
||||||
|
|
||||||
// APIKeys is a list of keys for authenticating clients to this proxy server.
|
type TLSConfig = internalconfig.TLSConfig
|
||||||
APIKeys []string `yaml:"api-keys" json:"api-keys"`
|
type RemoteManagement = internalconfig.RemoteManagement
|
||||||
|
type AmpCode = internalconfig.AmpCode
|
||||||
|
type PayloadConfig = internalconfig.PayloadConfig
|
||||||
|
type PayloadRule = internalconfig.PayloadRule
|
||||||
|
type PayloadModelRule = internalconfig.PayloadModelRule
|
||||||
|
|
||||||
// Access holds request authentication provider configuration.
|
type GeminiKey = internalconfig.GeminiKey
|
||||||
Access AccessConfig `yaml:"auth,omitempty" json:"auth,omitempty"`
|
type CodexKey = internalconfig.CodexKey
|
||||||
}
|
type ClaudeKey = internalconfig.ClaudeKey
|
||||||
|
type VertexCompatKey = internalconfig.VertexCompatKey
|
||||||
|
type VertexCompatModel = internalconfig.VertexCompatModel
|
||||||
|
type OpenAICompatibility = internalconfig.OpenAICompatibility
|
||||||
|
type OpenAICompatibilityAPIKey = internalconfig.OpenAICompatibilityAPIKey
|
||||||
|
type OpenAICompatibilityModel = internalconfig.OpenAICompatibilityModel
|
||||||
|
|
||||||
// AccessConfig groups request authentication providers.
|
type TLS = internalconfig.TLSConfig
|
||||||
type AccessConfig struct {
|
|
||||||
// Providers lists configured authentication providers.
|
|
||||||
Providers []AccessProvider `yaml:"providers,omitempty" json:"providers,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// AccessProvider describes a request authentication provider entry.
|
|
||||||
type AccessProvider struct {
|
|
||||||
// Name is the instance identifier for the provider.
|
|
||||||
Name string `yaml:"name" json:"name"`
|
|
||||||
|
|
||||||
// Type selects the provider implementation registered via the SDK.
|
|
||||||
Type string `yaml:"type" json:"type"`
|
|
||||||
|
|
||||||
// SDK optionally names a third-party SDK module providing this provider.
|
|
||||||
SDK string `yaml:"sdk,omitempty" json:"sdk,omitempty"`
|
|
||||||
|
|
||||||
// APIKeys lists inline keys for providers that require them.
|
|
||||||
APIKeys []string `yaml:"api-keys,omitempty" json:"api-keys,omitempty"`
|
|
||||||
|
|
||||||
// Config passes provider-specific options to the implementation.
|
|
||||||
Config map[string]any `yaml:"config,omitempty" json:"config,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// AccessProviderTypeConfigAPIKey is the built-in provider validating inline API keys.
|
AccessProviderTypeConfigAPIKey = internalconfig.AccessProviderTypeConfigAPIKey
|
||||||
AccessProviderTypeConfigAPIKey = "config-api-key"
|
DefaultAccessProviderName = internalconfig.DefaultAccessProviderName
|
||||||
|
DefaultPanelGitHubRepository = internalconfig.DefaultPanelGitHubRepository
|
||||||
// DefaultAccessProviderName is applied when no provider name is supplied.
|
|
||||||
DefaultAccessProviderName = "config-inline"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigAPIKeyProvider returns the first inline API key provider if present.
|
func MakeInlineAPIKeyProvider(keys []string) *AccessProvider {
|
||||||
func (c *SDKConfig) ConfigAPIKeyProvider() *AccessProvider {
|
return internalconfig.MakeInlineAPIKeyProvider(keys)
|
||||||
if c == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
for i := range c.Access.Providers {
|
|
||||||
if c.Access.Providers[i].Type == AccessProviderTypeConfigAPIKey {
|
|
||||||
if c.Access.Providers[i].Name == "" {
|
|
||||||
c.Access.Providers[i].Name = DefaultAccessProviderName
|
|
||||||
}
|
|
||||||
return &c.Access.Providers[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeInlineAPIKeyProvider constructs an inline API key provider configuration.
|
func LoadConfig(configFile string) (*Config, error) { return internalconfig.LoadConfig(configFile) }
|
||||||
// It returns nil when no keys are supplied.
|
|
||||||
func MakeInlineAPIKeyProvider(keys []string) *AccessProvider {
|
func LoadConfigOptional(configFile string, optional bool) (*Config, error) {
|
||||||
if len(keys) == 0 {
|
return internalconfig.LoadConfigOptional(configFile, optional)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
provider := &AccessProvider{
|
|
||||||
Name: DefaultAccessProviderName,
|
func SaveConfigPreserveComments(configFile string, cfg *Config) error {
|
||||||
Type: AccessProviderTypeConfigAPIKey,
|
return internalconfig.SaveConfigPreserveComments(configFile, cfg)
|
||||||
APIKeys: append([]string(nil), keys...),
|
|
||||||
}
|
}
|
||||||
return provider
|
|
||||||
|
func SaveConfigPreserveCommentsUpdateNestedScalar(configFile string, path []string, value string) error {
|
||||||
|
return internalconfig.SaveConfigPreserveCommentsUpdateNestedScalar(configFile, path, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NormalizeCommentIndentation(data []byte) []byte {
|
||||||
|
return internalconfig.NormalizeCommentIndentation(data)
|
||||||
}
|
}
|
||||||
|
|||||||
18
sdk/logging/request_logger.go
Normal file
18
sdk/logging/request_logger.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
// Package logging re-exports request logging primitives for SDK consumers.
|
||||||
|
package logging
|
||||||
|
|
||||||
|
import internallogging "github.com/router-for-me/CLIProxyAPI/v6/internal/logging"
|
||||||
|
|
||||||
|
// RequestLogger defines the interface for logging HTTP requests and responses.
|
||||||
|
type RequestLogger = internallogging.RequestLogger
|
||||||
|
|
||||||
|
// StreamingLogWriter handles real-time logging of streaming response chunks.
|
||||||
|
type StreamingLogWriter = internallogging.StreamingLogWriter
|
||||||
|
|
||||||
|
// FileRequestLogger implements RequestLogger using file-based storage.
|
||||||
|
type FileRequestLogger = internallogging.FileRequestLogger
|
||||||
|
|
||||||
|
// NewFileRequestLogger creates a new file-based request logger.
|
||||||
|
func NewFileRequestLogger(enabled bool, logsDir string, configDir string) *FileRequestLogger {
|
||||||
|
return internallogging.NewFileRequestLogger(enabled, logsDir, configDir)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user