mirror of
https://github.com/iv-org/invidious.git
synced 2025-07-29 16:58:30 +00:00
Config: Add scheme support to DBConfig
This commit is contained in:
parent
eab6efc42a
commit
a842f4358c
@ -1,12 +1,5 @@
|
|||||||
struct DBConfig
|
require "yaml"
|
||||||
include YAML::Serializable
|
require "./config/*"
|
||||||
|
|
||||||
property user : String
|
|
||||||
property password : String
|
|
||||||
property host : String
|
|
||||||
property port : Int32
|
|
||||||
property dbname : String
|
|
||||||
end
|
|
||||||
|
|
||||||
struct ConfigPreferences
|
struct ConfigPreferences
|
||||||
include YAML::Serializable
|
include YAML::Serializable
|
||||||
@ -69,7 +62,7 @@ class Config
|
|||||||
# Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.cr
|
# Default log level, valid YAML values are ints and strings, see src/invidious/helpers/logger.cr
|
||||||
property log_level : LogLevel = LogLevel::Info
|
property log_level : LogLevel = LogLevel::Info
|
||||||
# Database configuration with separate parameters (username, hostname, etc)
|
# Database configuration with separate parameters (username, hostname, etc)
|
||||||
property db : DBConfig? = nil
|
property db : IV::Config::DBConfig? = nil
|
||||||
|
|
||||||
# Database configuration using 12-Factor "Database URL" syntax
|
# Database configuration using 12-Factor "Database URL" syntax
|
||||||
@[YAML::Field(converter: Preferences::URIConverter)]
|
@[YAML::Field(converter: Preferences::URIConverter)]
|
||||||
|
23
src/invidious/config/db.cr
Normal file
23
src/invidious/config/db.cr
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module Invidious::Config
|
||||||
|
struct DBConfig
|
||||||
|
include YAML::Serializable
|
||||||
|
|
||||||
|
property scheme : String
|
||||||
|
property user : String
|
||||||
|
property password : String
|
||||||
|
property host : String
|
||||||
|
property port : Int32
|
||||||
|
property dbname : String
|
||||||
|
|
||||||
|
def to_uri
|
||||||
|
return URI.new(
|
||||||
|
scheme: @scheme,
|
||||||
|
user: @user,
|
||||||
|
password: @password,
|
||||||
|
host: @host,
|
||||||
|
port: @port,
|
||||||
|
path: @dbname,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user