@@ -6,22 +6,12 @@ use std::{collections::HashMap, path::PathBuf};
66
77use config:: { Config , ConfigError , Environment , File } ;
88use rfd_data:: content:: RfdTemplate ;
9- use serde:: {
10- de:: { self , Visitor } ,
11- Deserialize , Deserializer ,
12- } ;
13- use thiserror:: Error ;
9+ use serde:: Deserialize ;
1410use v_api:: config:: { AsymmetricKey , AuthnProviders , JwtConfig } ;
1511use v_model:: schema_ext:: MagicLinkMedium ;
1612
1713use crate :: server:: SpecConfig ;
1814
19- #[ derive( Debug , Error ) ]
20- pub enum AppConfigError {
21- #[ error( "Encountered invalid log format." ) ]
22- InvalidLogFormatVariant ,
23- }
24-
2515#[ derive( Debug , Deserialize ) ]
2616pub struct AppConfig {
2717 pub log_format : ServerLogFormat ,
@@ -40,42 +30,13 @@ pub struct AppConfig {
4030 pub services : ServicesConfig ,
4131}
4232
43- #[ derive( Debug ) ]
33+ #[ derive( Debug , Deserialize ) ]
34+ #[ serde( rename_all = "kebab-case" ) ]
4435pub enum ServerLogFormat {
4536 Json ,
4637 Pretty ,
4738}
4839
49- impl < ' de > Deserialize < ' de > for ServerLogFormat {
50- fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
51- where
52- D : Deserializer < ' de > ,
53- {
54- struct ExternalId ;
55-
56- impl < ' de > Visitor < ' de > for ExternalId {
57- type Value = ServerLogFormat ;
58-
59- fn expecting ( & self , formatter : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
60- formatter. write_str ( "string" )
61- }
62-
63- fn visit_str < E > ( self , value : & str ) -> Result < Self :: Value , E >
64- where
65- E : de:: Error ,
66- {
67- match value {
68- "json" => Ok ( Self :: Value :: Json ) ,
69- "pretty" => Ok ( Self :: Value :: Pretty ) ,
70- _ => Err ( de:: Error :: custom ( AppConfigError :: InvalidLogFormatVariant ) ) ,
71- }
72- }
73- }
74-
75- deserializer. deserialize_any ( ExternalId )
76- }
77- }
78-
7940#[ derive( Debug , Default , Deserialize ) ]
8041pub struct SearchConfig {
8142 pub host : String ,
0 commit comments