Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterHealth ¶
RegisterHealth はヘルスチェックエンドポイントを登録する。 このエンドポイントは Cloud Run のヘルスチェック互換を想定しており、 レートリミットやボディサイズ制限の影響を受けないようミドルウェア側の exempt path 設定で除外される前提で利用される。 想定外エラーが発生しない設計のため commonErrorCodes() は適用しない。
func RegisterRoutes ¶
func RegisterRoutes(api huma.API, compressHandler *handler.CompressHandler, convertHandler *handler.ConvertHandler)
RegisterRoutes はAPIルートを登録する。
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string
AllowedMethods []string
AllowedHeaders []string
AllowCredentials bool
MaxAge int
}
CORSConfig はCORSミドルウェアの設定を表す。
type Config ¶
type Config struct {
Host string
Port int
ShutdownTimeout time.Duration
ReadHeaderTimeout time.Duration
ReadTimeout time.Duration
WriteTimeout time.Duration
IdleTimeout time.Duration
CORS CORSConfig
BodyLimitBytes int64
RateLimit RateLimitConfig
Logging LoggingConfig
}
Config はAPIサーバーの設定を保持する。
func LoadConfig ¶
func LoadConfig(opts LoadConfigOptions) (Config, error)
LoadConfig は設定ファイル(YAML)と環境変数({EnvPrefix}_API_*)を読み込み、 Config を返す。設定ファイルが存在しない場合はデフォルト値で構築する。
type HealthOutput ¶
type HealthOutput struct {
Body struct {
Status string `json:"status" example:"ok" doc:"サーバーの稼働状態"`
}
}
HealthOutput はヘルスチェックのレスポンスを表す。
type LoadConfigOptions ¶
type LoadConfigOptions struct {
// ConfigName はファイル名(拡張子なし)。デフォルトは "default"。
ConfigName string
// ConfigType はファイル形式。デフォルトは "yaml"。
ConfigType string
// ConfigPaths は設定ファイルの探索パス。デフォルトは ["./configs", "."]。
ConfigPaths []string
// EnvPrefix は環境変数のプレフィックス。デフォルトは "LOKI"。
EnvPrefix string
}
LoadConfigOptions は LoadConfig の挙動をカスタマイズするためのオプション。
type LoggingConfig ¶
type LoggingConfig struct {
Level string // debug/info/warn/error
}
LoggingConfig はロギングミドルウェアの設定を表す。
type RateLimitConfig ¶
RateLimitConfig はレートリミットミドルウェアの設定を表す。
Directories
¶
| Path | Synopsis |
|---|---|
|
Package middleware はAPIサーバー用のChi互換ミドルウェアを提供する。
|
Package middleware はAPIサーバー用のChi互換ミドルウェアを提供する。 |
Click to show internal directories.
Click to hide internal directories.