File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change 7
7
using Microsoft . Extensions . DependencyInjection ;
8
8
using Microsoft . Extensions . Hosting ;
9
9
10
+ var builder = WebApplication . CreateBuilder ( ) ;
10
11
11
- // Load configuration
12
- if ( args . Length != 1 )
13
- {
14
- Console . Error . WriteLine ( "Usage: yarp.exe <config_file>" ) ;
15
- return 1 ;
16
- }
17
- var configFile = args [ 0 ] ;
18
- var fileInfo = new FileInfo ( configFile ) ;
19
- if ( ! fileInfo . Exists )
12
+ // Load configuration from file if passed
13
+ if ( args . Length == 1 )
20
14
{
21
- Console . Error . WriteLine ( $ "Could not find '{ configFile } '.") ;
22
- return 2 ;
15
+ var configFile = args [ 0 ] ;
16
+ var fileInfo = new FileInfo ( configFile ) ;
17
+ if ( ! fileInfo . Exists )
18
+ {
19
+ Console . Error . WriteLine ( $ "Could not find '{ configFile } '.") ;
20
+ return 2 ;
21
+ }
22
+ builder . Configuration . AddJsonFile ( fileInfo . FullName , optional : false , reloadOnChange : true ) ;
23
+ builder . Configuration . AddEnvironmentVariables ( ) ;
23
24
}
24
25
25
- var builder = WebApplication . CreateBuilder ( ) ;
26
- builder . Configuration . AddJsonFile ( fileInfo . FullName , optional : false , reloadOnChange : true ) ;
27
-
28
26
// Configure YARP
29
27
builder . AddServiceDefaults ( ) ;
30
28
builder . Services . AddServiceDiscovery ( ) ;
You can’t perform that action at this time.
0 commit comments