@@ -12,15 +12,15 @@ use super::*;
12
12
13
13
fn unknown_repo ( project : & str , repo : & str ) -> ApiError {
14
14
ApiError :: new (
15
- StatusCode :: NotFound ,
15
+ StatusCode :: NOT_FOUND ,
16
16
"404" . to_owned ( ) ,
17
17
format ! ( "project '{}' has no repository '{}'" , project, repo) ,
18
18
)
19
19
}
20
20
21
21
fn unknown_arch ( project : & str , repo : & str , arch : & str ) -> ApiError {
22
22
ApiError :: new (
23
- StatusCode :: NotFound ,
23
+ StatusCode :: NOT_FOUND ,
24
24
"404" . to_owned ( ) ,
25
25
format ! (
26
26
"repository '{}/{}' has no architecture '{}'" ,
@@ -31,7 +31,7 @@ fn unknown_arch(project: &str, repo: &str, arch: &str) -> ApiError {
31
31
32
32
fn unknown_parameter ( param : & str ) -> ApiError {
33
33
ApiError :: new (
34
- StatusCode :: BadRequest ,
34
+ StatusCode :: BAD_REQUEST ,
35
35
"400" . to_owned ( ) ,
36
36
format ! ( "unknown parameter '{}'" , param) ,
37
37
)
@@ -61,7 +61,7 @@ impl Respond for ProjectBuildCommandResponder {
61
61
62
62
let cmd = try_api ! (
63
63
find_query_param( request, "cmd" ) . ok_or_else( || ApiError :: new(
64
- StatusCode :: BadRequest ,
64
+ StatusCode :: BAD_REQUEST ,
65
65
"missing_parameter" . to_string( ) ,
66
66
"Missing parameter 'cmd'" . to_string( )
67
67
) )
@@ -76,7 +76,7 @@ impl Respond for ProjectBuildCommandResponder {
76
76
"package" => package_names. push ( value. clone ( ) . into_owned ( ) ) ,
77
77
"arch" | "repository" | "code" | "lastbuild" => {
78
78
return ApiError :: new (
79
- StatusCode :: MisdirectedRequest ,
79
+ StatusCode :: MISDIRECTED_REQUEST ,
80
80
"unsupported" . to_string ( ) ,
81
81
"Operation not supported by the OBS mock server" . to_owned ( ) ,
82
82
)
@@ -106,7 +106,7 @@ impl Respond for ProjectBuildCommandResponder {
106
106
inner_xml. render ( & mut inner, false , true ) . unwrap ( ) ;
107
107
108
108
return ApiError :: new (
109
- StatusCode :: NotFound ,
109
+ StatusCode :: NOT_FOUND ,
110
110
"not_found" . to_owned ( ) ,
111
111
String :: from_utf8_lossy ( & inner) . into_owned ( ) ,
112
112
)
@@ -134,10 +134,10 @@ impl Respond for ProjectBuildCommandResponder {
134
134
}
135
135
}
136
136
137
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( build_status_xml ( "ok" , None ) )
137
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( build_status_xml ( "ok" , None ) )
138
138
}
139
139
_ => ApiError :: new (
140
- StatusCode :: BadRequest ,
140
+ StatusCode :: BAD_REQUEST ,
141
141
"illegal_request" . to_owned ( ) ,
142
142
format ! ( "unsupported POST command {} to {}" , cmd, request. url) ,
143
143
)
@@ -213,7 +213,7 @@ impl Respond for ArchListingResponder {
213
213
xml. add_child ( child_xml) . unwrap ( ) ;
214
214
}
215
215
216
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( xml)
216
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( xml)
217
217
}
218
218
}
219
219
@@ -330,7 +330,7 @@ impl Respond for BuildJobHistoryResponder {
330
330
"code" => code_names. push ( value. into_owned ( ) ) ,
331
331
"limit" if limit. is_some ( ) => {
332
332
return ApiError :: new (
333
- StatusCode :: Ok ,
333
+ StatusCode :: OK ,
334
334
"400" . to_owned ( ) ,
335
335
"parameter 'limit' set multiple times" . to_owned ( ) ,
336
336
)
@@ -410,7 +410,7 @@ impl Respond for BuildJobHistoryResponder {
410
410
}
411
411
}
412
412
413
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( xml)
413
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( xml)
414
414
}
415
415
}
416
416
@@ -465,7 +465,7 @@ impl Respond for BuildBinaryListResponder {
465
465
}
466
466
}
467
467
468
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( xml)
468
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( xml)
469
469
}
470
470
}
471
471
@@ -513,11 +513,11 @@ impl Respond for BuildBinaryFileResponder {
513
513
let file = try_api ! ( package
514
514
. and_then( |package| package. binaries. get( file_name) )
515
515
. ok_or_else( || ApiError :: new(
516
- StatusCode :: NotFound ,
516
+ StatusCode :: NOT_FOUND ,
517
517
"404" . to_owned( ) ,
518
518
format!( "{}: No such file or directory" , file_name)
519
519
) ) ) ;
520
- ResponseTemplate :: new ( StatusCode :: Ok )
520
+ ResponseTemplate :: new ( StatusCode :: OK )
521
521
. set_body_raw ( file. contents . clone ( ) , "application/octet-stream" )
522
522
}
523
523
}
@@ -562,7 +562,7 @@ impl Respond for BuildPackageStatusResponder {
562
562
. ok_or_else( || unknown_arch( project_name, repo_name, arch) ) ) ;
563
563
564
564
let package = arch. packages . get ( package_name) ;
565
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( package. map_or_else (
565
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( package. map_or_else (
566
566
|| {
567
567
package_status_xml (
568
568
package_name,
@@ -587,15 +587,15 @@ impl BuildLogResponder {
587
587
fn parse_number_param ( value : Cow < str > ) -> Result < usize , ApiError > {
588
588
if value. is_empty ( ) {
589
589
return Err ( ApiError :: new (
590
- StatusCode :: BadRequest ,
590
+ StatusCode :: BAD_REQUEST ,
591
591
"400" . to_owned ( ) ,
592
592
"number is empty" . to_owned ( ) ,
593
593
) ) ;
594
594
}
595
595
596
596
value. as_ref ( ) . parse ( ) . map_err ( |_| {
597
597
ApiError :: new (
598
- StatusCode :: BadRequest ,
598
+ StatusCode :: BAD_REQUEST ,
599
599
"400" . to_owned ( ) ,
600
600
format ! ( "not a number: '{}'" , value) ,
601
601
)
@@ -607,7 +607,7 @@ fn parse_bool_param(value: Cow<str>) -> Result<bool, ApiError> {
607
607
"1" => Ok ( true ) ,
608
608
"0" => Ok ( false ) ,
609
609
_ => Err ( ApiError :: new (
610
- StatusCode :: BadRequest ,
610
+ StatusCode :: BAD_REQUEST ,
611
611
"400" . to_owned ( ) ,
612
612
"not a boolean" . to_owned ( ) ,
613
613
) ) ,
@@ -646,7 +646,7 @@ impl Respond for BuildLogResponder {
646
646
ensure ! (
647
647
value == "entry" ,
648
648
ApiError :: new(
649
- StatusCode :: BadRequest ,
649
+ StatusCode :: BAD_REQUEST ,
650
650
"400" . to_owned( ) ,
651
651
format!( "unknown view '{}'" , value)
652
652
)
@@ -682,7 +682,7 @@ impl Respond for BuildLogResponder {
682
682
. get( arch)
683
683
. ok_or_else( || unknown_arch( project_name, repo_name, arch) ) ) ;
684
684
let package = try_api ! ( arch. packages. get( package_name) . ok_or_else( || ApiError :: new(
685
- StatusCode :: BadRequest ,
685
+ StatusCode :: BAD_REQUEST ,
686
686
"400" . to_owned( ) ,
687
687
format!( "remote error: {} no logfile" , package_name)
688
688
) ) ) ;
@@ -706,13 +706,13 @@ impl Respond for BuildLogResponder {
706
706
xml. add_child ( entry_xml) . unwrap ( ) ;
707
707
}
708
708
709
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( xml)
709
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( xml)
710
710
} else {
711
711
let contents = log. as_ref ( ) . map_or ( "" , |log| & log. contents ) ;
712
712
ensure ! (
713
713
start <= contents. len( ) ,
714
714
ApiError :: new(
715
- StatusCode :: BadRequest ,
715
+ StatusCode :: BAD_REQUEST ,
716
716
"400" . to_owned( ) ,
717
717
format!( "remote error: start out of range {}" , start)
718
718
)
@@ -727,7 +727,7 @@ impl Respond for BuildLogResponder {
727
727
. unwrap_or ( end) ,
728
728
) ;
729
729
730
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_string ( & contents[ start..end] )
730
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_string ( & contents[ start..end] )
731
731
}
732
732
}
733
733
}
@@ -791,6 +791,6 @@ impl Respond for BuildHistoryResponder {
791
791
}
792
792
}
793
793
794
- ResponseTemplate :: new ( StatusCode :: Ok ) . set_body_xml ( xml)
794
+ ResponseTemplate :: new ( StatusCode :: OK ) . set_body_xml ( xml)
795
795
}
796
796
}
0 commit comments