Skip to content

Commit

Permalink
feat(#9): {port}
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed Jun 1, 2024
1 parent 0e387c8 commit ee64f37
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 57 deletions.
64 changes: 32 additions & 32 deletions resources/home.json
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"current_user_url": "http://localhost:3000/user",
"current_user_url": "http://localhost:{port}/user",
"current_user_authorizations_html_url": "https://github.com/settings/connections/applications{/client_id}",
"authorizations_url": "http://localhost:3000/authorizations",
"code_search_url": "http://localhost:3000/search/code?q={query}{&page,per_page,sort,order}",
"commit_search_url": "http://localhost:3000/search/commits?q={query}{&page,per_page,sort,order}",
"emails_url": "http://localhost:3000/user/emails",
"emojis_url": "http://localhost:3000/emojis",
"events_url": "http://localhost:3000/events",
"feeds_url": "http://localhost:3000/feeds",
"followers_url": "http://localhost:3000/user/followers",
"following_url": "http://localhost:3000/user/following{/target}",
"gists_url": "http://localhost:3000/gists{/gist_id}",
"hub_url": "http://localhost:3000/hub",
"issue_search_url": "http://localhost:3000/search/issues?q={query}{&page,per_page,sort,order}",
"issues_url": "http://localhost:3000/issues",
"keys_url": "http://localhost:3000/user/keys",
"label_search_url": "http://localhost:3000/search/labels?q={query}&repository_id={repository_id}{&page,per_page}",
"notifications_url": "http://localhost:3000/notifications",
"organization_url": "http://localhost:3000/orgs/{org}",
"organization_repositories_url": "http://localhost:3000/orgs/{org}/repos{?type,page,per_page,sort}",
"organization_teams_url": "http://localhost:3000/orgs/{org}/teams",
"public_gists_url": "http://localhost:3000/gists/public",
"rate_limit_url": "http://localhost:3000/rate_limit",
"repository_url": "http://localhost:3000/repos/{owner}/{repo}",
"repository_search_url": "http://localhost:3000/search/repositories?q={query}{&page,per_page,sort,order}",
"current_user_repositories_url": "http://localhost:3000/user/repos{?type,page,per_page,sort}",
"starred_url": "http://localhost:3000/user/starred{/owner}{/repo}",
"starred_gists_url": "http://localhost:3000/gists/starred",
"topic_search_url": "http://localhost:3000/search/topics?q={query}{&page,per_page}",
"user_url": "http://localhost:3000/users/{user}",
"user_organizations_url": "http://localhost:3000/user/orgs",
"user_repositories_url": "http://localhost:3000/users/{user}/repos{?type,page,per_page,sort}",
"user_search_url": "http://localhost:3000/search/users?q={query}{&page,per_page,sort,order}"
"authorizations_url": "http://localhost:{port}/authorizations",
"code_search_url": "http://localhost:{port}/search/code?q={query}{&page,per_page,sort,order}",
"commit_search_url": "http://localhost:{port}/search/commits?q={query}{&page,per_page,sort,order}",
"emails_url": "http://localhost:{port}/user/emails",
"emojis_url": "http://localhost:{port}/emojis",
"events_url": "http://localhost:{port}/events",
"feeds_url": "http://localhost:{port}/feeds",
"followers_url": "http://localhost:{port}/user/followers",
"following_url": "http://localhost:{port}/user/following{/target}",
"gists_url": "http://localhost:{port}/gists{/gist_id}",
"hub_url": "http://localhost:{port}/hub",
"issue_search_url": "http://localhost:{port}/search/issues?q={query}{&page,per_page,sort,order}",
"issues_url": "http://localhost:{port}/issues",
"keys_url": "http://localhost:{port}/user/keys",
"label_search_url": "http://localhost:{port}/search/labels?q={query}&repository_id={repository_id}{&page,per_page}",
"notifications_url": "http://localhost:{port}/notifications",
"organization_url": "http://localhost:{port}/orgs/{org}",
"organization_repositories_url": "http://localhost:{port}/orgs/{org}/repos{?type,page,per_page,sort}",
"organization_teams_url": "http://localhost:{port}/orgs/{org}/teams",
"public_gists_url": "http://localhost:{port}/gists/public",
"rate_limit_url": "http://localhost:{port}/rate_limit",
"repository_url": "http://localhost:{port}/repos/{owner}/{repo}",
"repository_search_url": "http://localhost:{port}/search/repositories?q={query}{&page,per_page,sort,order}",
"current_user_repositories_url": "http://localhost:{port}/user/repos{?type,page,per_page,sort}",
"starred_url": "http://localhost:{port}/user/starred{/owner}{/repo}",
"starred_gists_url": "http://localhost:{port}/gists/starred",
"topic_search_url": "http://localhost:{port}/search/topics?q={query}{&page,per_page}",
"user_url": "http://localhost:{port}/users/{user}",
"user_organizations_url": "http://localhost:{port}/user/orgs",
"user_repositories_url": "http://localhost:{port}/users/{user}/repos{?type,page,per_page,sort}",
"user_search_url": "http://localhost:{port}/search/users?q={query}{&page,per_page,sort,order}"
}
39 changes: 14 additions & 25 deletions src/home.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,11 @@
// The MIT License (MIT)
//
// Copyright (c) 2024 Aliaksei Bialiauski
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
use std::io;
use tokio::fs;
use std::collections::HashMap;
use std::error::Error;

use axum::http::StatusCode;
use axum::Json;
use axum::response::IntoResponse;
use tokio::fs;

use crate::rs_err::RsErr;

pub async fn home() -> impl IntoResponse {
Expand All @@ -46,6 +28,13 @@ pub async fn home() -> impl IntoResponse {
}
}

async fn json(path: &str) -> io::Result<String> {
fs::read_to_string(path).await
async fn json(path: &str) -> Result<String, Box<dyn Error>> {
let content = fs::read_to_string(path).await.unwrap();
let mut data: HashMap<String, String> = serde_json::from_str(&content)
.unwrap();
for (_, value) in &mut data {
*value = value.replace("{port}", "3000");
}
let updated = serde_json::to_string(&data).unwrap();
Ok(updated)
}

0 comments on commit ee64f37

Please sign in to comment.