Skip to content

Commit

Permalink
Remove obsolete routes.
Browse files Browse the repository at this point in the history
Now that we are not syncing via wasm the routes used for the local sync
protocol are no longer relevant and have been removed.
  • Loading branch information
tmpfs committed Dec 8, 2024
1 parent 37de163 commit b12990b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 619 deletions.
243 changes: 0 additions & 243 deletions crates/ipc/src/web_service/account.rs

This file was deleted.

35 changes: 2 additions & 33 deletions crates/ipc/src/web_service/common.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
use std::collections::HashMap;

use bytes::Bytes;
use http::{
header::{CONNECTION, CONTENT_TYPE},
Request, Response, StatusCode, Uri,
};
use http::{header::CONTENT_TYPE, Request, Response, StatusCode, Uri};
use http_body_util::{BodyExt, Full};
use serde::Serialize;
use sos_protocol::constants::{
MIME_TYPE_JSON, MIME_TYPE_PROTOBUF, X_SOS_ACCOUNT_ID,
};
use sos_protocol::constants::{MIME_TYPE_JSON, X_SOS_ACCOUNT_ID};
use sos_sdk::{prelude::Address, url::form_urlencoded};

use super::{Body, Incoming};
Expand All @@ -26,7 +21,6 @@ pub fn parse_query(uri: &Uri) -> HashMap<String, String> {
let Some(query) = parts.last() else {
return Default::default();
};

let it = form_urlencoded::parse(query.as_bytes());
it.map(|(k, v)| (k.into_owned(), v.into_owned()))
.collect::<HashMap<_, _>>()
Expand Down Expand Up @@ -55,25 +49,10 @@ pub fn status(status: StatusCode) -> hyper::Result<Response<Body>> {
.unwrap())
}

pub fn bad_request() -> hyper::Result<Response<Body>> {
status(StatusCode::BAD_REQUEST)
}

pub fn forbidden() -> hyper::Result<Response<Body>> {
status(StatusCode::FORBIDDEN)
}

pub fn not_found() -> hyper::Result<Response<Body>> {
status(StatusCode::NOT_FOUND)
}

pub fn ok(body: Body) -> hyper::Result<Response<Body>> {
Ok(Response::builder()
.status(StatusCode::OK)
.body(body)
.unwrap())
}

pub fn internal_server_error(
e: impl std::fmt::Display,
) -> hyper::Result<Response<Body>> {
Expand Down Expand Up @@ -101,13 +80,3 @@ pub fn json<S: Serialize>(
.unwrap();
Ok(response)
}

pub fn protobuf_compress(buf: Vec<u8>) -> hyper::Result<Response<Body>> {
Ok(Response::builder()
.status(StatusCode::OK)
// .header(CONTENT_ENCODING, ENCODING_ZLIB)
.header(CONTENT_TYPE, MIME_TYPE_PROTOBUF)
.header(CONNECTION, "close")
.body(Full::new(Bytes::from(buf)))
.unwrap())
}
Loading

0 comments on commit b12990b

Please sign in to comment.