MCPcopy Create free account
hub / github.com/actix/examples / api_versioning

Function api_versioning

guards/src/main.rs:83–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81
82 #[actix_web::test]
83 async fn api_versioning() {
84 let app = test::init_service(create_app()).await;
85
86 let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "1"));
87 let res = test::call_and_read_body(&app, req.to_request()).await;
88 assert_eq!(res, "Hello World from v1 API!");
89
90 let req = TestRequest::with_uri("/api/hello").insert_header(("Accept-Version", "2"));
91 let res = test::call_and_read_body(&app, req.to_request()).await;
92 assert_eq!(res, "Hello World from the awesome new v2 API!");
93 }
94}

Callers

nothing calls this directly

Calls 1

create_appFunction · 0.85

Tested by

no test coverage detected