File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,9 @@ pub struct EmailArgs {
144
144
pub enum OpenApiSubCommands {
145
145
Print ,
146
146
Run {
147
- #[ arg( long, default_value_t = 4004 ) ]
148
- port : u16 ,
147
+ /// Authority (<host>:<port>) the HTTP server binds to (Default: localhost:4000).
148
+ #[ arg( short, long, env, default_value = "localhost:4004" ) ]
149
+ address : String ,
149
150
} ,
150
151
}
151
152
Original file line number Diff line number Diff line change @@ -97,12 +97,11 @@ async fn async_main() -> Result<(), BoxError> {
97
97
use utoipa:: OpenApi ;
98
98
use utoipa_swagger_ui:: SwaggerUi ;
99
99
100
- let run_server = |port : u16 | async move {
100
+ let run_server = |addr : String | async move {
101
101
let router = axum:: Router :: new ( ) . merge (
102
102
SwaggerUi :: new ( "/docs" ) . url ( "/api/openapi.json" , trailbase:: openapi:: Doc :: openapi ( ) ) ,
103
103
) ;
104
104
105
- let addr = format ! ( "localhost:{port}" ) ;
106
105
let listener = tokio:: net:: TcpListener :: bind ( addr. clone ( ) ) . await . unwrap ( ) ;
107
106
log:: info!( "docs @ http://{addr}/docs 🚀" ) ;
108
107
@@ -114,11 +113,11 @@ async fn async_main() -> Result<(), BoxError> {
114
113
let json = trailbase:: openapi:: Doc :: openapi ( ) . to_pretty_json ( ) ?;
115
114
println ! ( "{json}" ) ;
116
115
}
117
- Some ( OpenApiSubCommands :: Run { port } ) => {
118
- run_server ( port ) . await ;
116
+ Some ( OpenApiSubCommands :: Run { address } ) => {
117
+ run_server ( address ) . await ;
119
118
}
120
119
None => {
121
- run_server ( 4004 ) . await ;
120
+ run_server ( "localhost: 4004" . to_string ( ) ) . await ;
122
121
}
123
122
}
124
123
}
You can’t perform that action at this time.
0 commit comments