rename domain to site in the backend
This commit is contained in:
parent
fa691d7c59
commit
e162dc988c
1 changed files with 7 additions and 7 deletions
|
@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
struct WebringMember {
|
struct WebringMember {
|
||||||
name: String,
|
name: String,
|
||||||
domain: String,
|
site: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[web::get("/next/{name}")]
|
#[web::get("/next/{name}")]
|
||||||
|
@ -18,8 +18,8 @@ async fn next(
|
||||||
) -> impl web::Responder {
|
) -> impl web::Responder {
|
||||||
if let Some((i, _)) = members.iter().enumerate().find(|(_, member)| member.name == *name) {
|
if let Some((i, _)) = members.iter().enumerate().find(|(_, member)| member.name == *name) {
|
||||||
let next_index = (i + 1) % members.len();
|
let next_index = (i + 1) % members.len();
|
||||||
let next_domain = &members[next_index].domain;
|
let next_site = &members[next_index].site;
|
||||||
let next_url = format!("https://{next_domain}/");
|
let next_url = format!("https://{next_site}/");
|
||||||
|
|
||||||
return Response::PermanentRedirect()
|
return Response::PermanentRedirect()
|
||||||
.header(header::LOCATION, next_url)
|
.header(header::LOCATION, next_url)
|
||||||
|
@ -40,8 +40,8 @@ async fn prev(
|
||||||
) -> impl web::Responder {
|
) -> impl web::Responder {
|
||||||
if let Some((i, _)) = members.iter().enumerate().find(|(_, member)| member.name == *name) {
|
if let Some((i, _)) = members.iter().enumerate().find(|(_, member)| member.name == *name) {
|
||||||
let prev_index = if i == 0 { members.len() - 1 } else { i - 1 };
|
let prev_index = if i == 0 { members.len() - 1 } else { i - 1 };
|
||||||
let prev_domain = &members[prev_index].domain;
|
let prev_site = &members[prev_index].site;
|
||||||
let prev_url = format!("https://{prev_domain}/");
|
let prev_url = format!("https://{prev_site}/");
|
||||||
|
|
||||||
return Response::PermanentRedirect()
|
return Response::PermanentRedirect()
|
||||||
.header(header::LOCATION, prev_url)
|
.header(header::LOCATION, prev_url)
|
||||||
|
@ -60,8 +60,8 @@ async fn rand(
|
||||||
members: web::types::State<Vec<WebringMember>>,
|
members: web::types::State<Vec<WebringMember>>,
|
||||||
) -> impl web::Responder {
|
) -> impl web::Responder {
|
||||||
let rand_index = thread_rng().gen_range(0..members.len());
|
let rand_index = thread_rng().gen_range(0..members.len());
|
||||||
let rand_domain = &members[rand_index].domain;
|
let rand_site = &members[rand_index].site;
|
||||||
let rand_url = format!("https://{rand_domain}/");
|
let rand_url = format!("https://{rand_site}/");
|
||||||
|
|
||||||
Response::PermanentRedirect()
|
Response::PermanentRedirect()
|
||||||
.header(header::LOCATION, rand_url)
|
.header(header::LOCATION, rand_url)
|
||||||
|
|
Loading…
Reference in a new issue