Removed address, added host and port, removed comments

This commit is contained in:
perp 2024-06-06 19:15:27 +01:00
parent bd37727a03
commit a2dfee4a77
3 changed files with 19 additions and 57 deletions

View File

@ -1,33 +1,22 @@
[auth]
# JWT secret
secret = "a secret"
# Disable registration
disabled = false
# bcrypt cost
# https://pkg.go.dev/golang.org/x/crypto/bcrypt#pkg-constants
cost = 10
[server] [server]
# Listener address host = "127.0.0.1"
address = "127.0.0.1:8080" port = 8080
# Read & write timeout
# Warning: Too high can
# cause a slowloris attack
read_timeout = 10 read_timeout = 10
write_timeout = 10 write_timeout = 10
[database] [database]
# Supported drivers:
# sqlite3
driver = "sqlite3" driver = "sqlite3"
# URL (For sqlite, use the path)
url = "gopay.db" url = "gopay.db"
# Max connections
max = 30 max = 30
# Max idle connections
idle = 30 idle = 30
[auth]
secret = "a secret"
register = false
# https://pkg.go.dev/golang.org/x/crypto/bcrypt#pkg-constants
cost = 10
[log] [log]
# Level for database and server
# https://pkg.go.dev/github.com/rs/zerolog#Level # https://pkg.go.dev/github.com/rs/zerolog#Level
level = "debug" level = "debug"

View File

@ -1,37 +1,17 @@
// Copyright 2024 perp (supernets)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config package config
// Configuration // Configuration
type Config struct { type Config struct {
Auth *Auth
Server *Server Server *Server
Database *Database Database *Database
Auth *Auth
Log *Log Log *Log
} }
// Auth configuration
type Auth struct {
Secret string `toml:"secret"`
Disabled bool `toml:"disabled"`
Cost int `toml:"cost"`
}
// Server configuration // Server configuration
type Server struct { type Server struct {
Address string `toml:"address"` Host string `toml:"host"`
Port int `toml:"port"`
ReadTimeout int `toml:"read_timeout"` ReadTimeout int `toml:"read_timeout"`
WriteTimeout int `toml:"write_timeout"` WriteTimeout int `toml:"write_timeout"`
} }
@ -44,6 +24,13 @@ type Database struct {
Idle int `toml:"idle"` Idle int `toml:"idle"`
} }
// Auth configuration
type Auth struct {
Secret string `toml:"secret"`
Register bool `toml:"register"`
Cost int `toml:"cost"`
}
// Log configuration // Log configuration
type Log struct { type Log struct {
Level string `toml:"level"` Level string `toml:"level"`

View File

@ -1,17 +1,3 @@
// Copyright 2024 perp (supernets)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package config package config
import ( import (