config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultInvoiceBaseURL is the production origin for the MoneyForward
	// Invoice API v3. It is exported so packages outside config (e.g.
	// internal/api) can fall back to the same default when callers
	// construct a Config manually without going through Load.
	DefaultInvoiceBaseURL = "https://invoice.moneyforward.com"
)

Variables

This section is empty.

Functions

func NormalizeInvoiceBaseURL added in v0.2.0

func NormalizeInvoiceBaseURL(raw string) (string, error)

NormalizeInvoiceBaseURL validates and normalizes a raw Invoice API base URL value. It is exported so api.NewInvoiceClient can apply the same strict rules to manually constructed Config values without relying on Load.

Rules:

  • Empty / whitespace-only input falls back to DefaultInvoiceBaseURL.
  • Scheme must be http or https.
  • Host must be present.
  • RawQuery, Fragment, and Userinfo must be empty.
  • Trailing slashes are trimmed; a trailing "/api/v3" segment is also trimmed (origin-only contract). Any other non-empty path is rejected.

Types

type Config

type Config struct {
	ClientID       string `json:"client_id"`
	ClientSecret   string `json:"client_secret"`
	BaseURL        string `json:"base_url"`
	InvoiceBaseURL string `json:"invoice_base_url"`
	ConfigDir      string `json:"-"`
	AuthPort       int    `json:"auth_port"`
}

func Load

func Load() (*Config, error)

func (*Config) RequireClientID

func (c *Config) RequireClientID() error

RequireClientID returns an error if ClientID is not set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL