File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ use axum::{
5
5
} ;
6
6
use serde:: Serialize ;
7
7
8
+ #[ derive( Debug ) ]
8
9
pub struct AppError {
9
10
/// An error message.
10
11
pub error : anyhow:: Error ,
Original file line number Diff line number Diff line change
1
+ use std:: time:: Duration ;
2
+
1
3
use axum:: {
2
4
routing:: { get, post} ,
3
5
Router ,
@@ -9,26 +11,29 @@ use shutdown_signal::shutdown_signal;
9
11
10
12
mod speech;
11
13
use speech:: speech;
14
+ use unspeech_shared:: AppError ;
12
15
13
16
#[ tokio:: main]
14
- async fn main ( ) {
17
+ async fn main ( ) -> Result < ( ) , AppError > {
15
18
tracing_subscriber:: fmt:: init ( ) ;
16
19
17
- let client = Client :: new ( ) ;
20
+ let client = Client :: builder ( )
21
+ . timeout ( Duration :: from_secs ( 60 ) )
22
+ . build ( ) ?;
18
23
19
24
let app = Router :: new ( )
20
25
. route ( "/" , get ( root) )
21
26
. route ( "/v1/audio/speech" , post ( speech) )
22
27
. with_state ( client) ;
23
28
24
29
let listener = tokio:: net:: TcpListener :: bind ( "127.0.0.1:3000" )
25
- . await
26
- . unwrap ( ) ;
30
+ . await ?;
27
31
28
- axum:: serve ( listener, app)
29
- . with_graceful_shutdown ( shutdown_signal ( ) )
30
- . await
31
- . unwrap ( ) ;
32
+ Ok (
33
+ axum:: serve ( listener, app)
34
+ . with_graceful_shutdown ( shutdown_signal ( ) )
35
+ . await ?
36
+ )
32
37
}
33
38
34
39
async fn root ( ) -> & ' static str {
You can’t perform that action at this time.
0 commit comments