block logic

This commit is contained in:
2025-12-17 11:09:54 +02:00
parent d78a6bedd5
commit cda0edfde2
4 changed files with 133 additions and 15 deletions

View File

@@ -2,15 +2,29 @@ package config
import (
"sync/atomic"
"time"
"github.com/akyaiy/GSfass/core/config"
)
type StaticConfig struct {
Enabled bool `mapstructure:"enabled"`
Dir string `mapstructure:"static_dir"`
IndexFile string `mapstructure:"index_file"`
}
type BlockConfig struct {
Enabled bool `mapstructure:"enabled"`
BlockDir string `mapstructure:"block_dir"`
}
type ServerConfig struct {
Port int `mapstructure:"port"`
Addr string `mapstructure:"address"`
StaticFilesPath string `mapstructure:"static_dir"`
LogPath string `mapstructure:"log_path"`
StaticConfig StaticConfig `mapstructure:"static"`
BlockConfig BlockConfig `mapstructure:"block"`
Port int `mapstructure:"port"`
Addr string `mapstructure:"address"`
LogPath string `mapstructure:"log_path"`
TimeoutSeconds time.Duration `mapstructure:"timeout_seconds"`
}
type FuncConfig struct {
@@ -24,9 +38,15 @@ type Config struct {
var configPath atomic.Value // string
var defaults = map[string]any{
"server.port": 8080,
"server.address": "127.0.0.0",
"server.static_dir": "./static",
"server.port": 8080,
"server.address": "127.0.0.0",
"server.timeout_seconds": 5,
"server.log_path": "./logs/server.log",
"server.static.enabled": true,
"server.static.static_dir": "./static",
"server.static.index_file": "index.html",
"server.block.enabled": true,
"server.block.block_dir": "./blocks",
"functions.func_dir": "./functions",
}