Allow the zed app to connect to both the old and new rpc endpoints

In the case of the new Next.js app, the app will follow a redirect
from 'zed.dev/rpc' to the subdomain where the rust service is hosted.
Until then, the app will connect directly to zed.dev/rpc.
This commit is contained in:
Max Brunsfeld 2022-01-03 15:20:40 -08:00
parent f499a1dfc2
commit a080ae98c6
16 changed files with 107 additions and 72 deletions

View file

@ -898,7 +898,7 @@ impl Collaborator {
#[cfg(test)]
mod tests {
use super::*;
use client::{http::ServerResponse, test::FakeHttpClient};
use client::test::FakeHttpClient;
use fs::RealFs;
use gpui::TestAppContext;
use language::LanguageRegistry;
@ -1004,8 +1004,8 @@ mod tests {
fn build_project(cx: &mut TestAppContext) -> ModelHandle<Project> {
let languages = Arc::new(LanguageRegistry::new());
let fs = Arc::new(RealFs);
let client = client::Client::new();
let http_client = FakeHttpClient::new(|_| async move { Ok(ServerResponse::new(404)) });
let http_client = FakeHttpClient::with_404_response();
let client = client::Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
cx.update(|cx| Project::local(client, user_store, languages, fs, cx))
}

View file

@ -3054,8 +3054,8 @@ mod tests {
)
.await;
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3092,8 +3092,8 @@ mod tests {
"file1": "the old contents",
}));
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3127,8 +3127,8 @@ mod tests {
}));
let file_path = dir.path().join("file1");
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3176,7 +3176,8 @@ mod tests {
}));
let user_id = 5;
let mut client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let mut client = Client::new(http_client.clone());
let server = FakeServer::for_client(user_id, &mut client, &cx).await;
let user_store = server.build_user_store(client.clone(), &mut cx).await;
let tree = Worktree::open_local(
@ -3221,7 +3222,7 @@ mod tests {
1,
1,
initial_snapshot.to_proto(),
Client::new(),
Client::new(http_client.clone()),
user_store,
Default::default(),
&mut cx.to_async(),
@ -3327,8 +3328,8 @@ mod tests {
}
}));
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3369,7 +3370,8 @@ mod tests {
#[gpui::test]
async fn test_buffer_deduping(mut cx: gpui::TestAppContext) {
let user_id = 100;
let mut client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let mut client = Client::new(http_client);
let server = FakeServer::for_client(user_id, &mut client, &cx).await;
let user_store = server.build_user_store(client.clone(), &mut cx).await;
@ -3433,8 +3435,8 @@ mod tests {
"file2": "def",
"file3": "ghi",
}));
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3570,8 +3572,8 @@ mod tests {
let initial_contents = "aaa\nbbbbb\nc\n";
let dir = temp_tree(json!({ "the-file": initial_contents }));
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3687,8 +3689,8 @@ mod tests {
"b.rs": "const y: i32 = 1",
}));
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
let tree = Worktree::open_local(
@ -3755,8 +3757,8 @@ mod tests {
#[gpui::test]
async fn test_grouped_diagnostics(mut cx: gpui::TestAppContext) {
let fs = Arc::new(FakeFs::new());
let client = Client::new();
let http_client = FakeHttpClient::with_404_response();
let client = Client::new(http_client.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http_client, cx));
fs.insert_tree(