Skip to content

Commit

Permalink
refector(api): move API_VERSION const out of ActixWeb implementation
Browse files Browse the repository at this point in the history
We are going to remove the ActixWeb implementation after enabling the
new Axum implementaion. WE are moving generic things in ActixWeb
implementations that are not going to be removed.
  • Loading branch information
josecelano committed Jun 19, 2023
1 parent a6881e3 commit 9591239
Show file tree
Hide file tree
Showing 12 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/mailer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use serde::{Deserialize, Serialize};

use crate::config::Configuration;
use crate::errors::ServiceError;
use crate::routes::API_VERSION;
use crate::utils::clock;
use crate::web::api::API_VERSION;

pub struct Service {
cfg: Arc<Configuration>,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use actix_web::http::StatusCode;
use actix_web::{web, HttpResponse, Responder};

use crate::errors::ServiceResult;
use crate::routes::API_VERSION;
use crate::services::about::{index_page, license_page};
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 1 addition & 1 deletion src/routes/category.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use crate::common::WebAppData;
use crate::errors::ServiceResult;
use crate::models::response::OkResponse;
use crate::routes::API_VERSION;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 0 additions & 2 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ pub mod tag;
pub mod torrent;
pub mod user;

pub const API_VERSION: &str = "v1";

pub fn init(cfg: &mut web::ServiceConfig) {
user::init(cfg);
torrent::init(cfg);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use actix_web::{web, HttpRequest, HttpResponse, Responder};
use crate::cache::image::manager::Error;
use crate::common::WebAppData;
use crate::errors::ServiceResult;
use crate::routes::API_VERSION;
use crate::ui::proxy::{load_error_images, map_error_to_image};
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
3 changes: 2 additions & 1 deletion src/routes/root.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use actix_web::web;

use crate::routes::{about, API_VERSION};
use crate::routes::about;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(web::scope("/").service(web::resource("").route(web::get().to(about::get))));
Expand Down
2 changes: 1 addition & 1 deletion src/routes/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::common::WebAppData;
use crate::config;
use crate::errors::ServiceResult;
use crate::models::response::OkResponse;
use crate::routes::API_VERSION;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 1 addition & 1 deletion src/routes/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::common::WebAppData;
use crate::errors::ServiceResult;
use crate::models::response::OkResponse;
use crate::models::torrent_tag::TagId;
use crate::routes::API_VERSION;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 1 addition & 1 deletion src/routes/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::models::info_hash::InfoHash;
use crate::models::response::{NewTorrentResponse, OkResponse};
use crate::models::torrent::TorrentRequest;
use crate::models::torrent_tag::TagId;
use crate::routes::API_VERSION;
use crate::services::torrent::ListingRequest;
use crate::utils::parse_torrent;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 1 addition & 1 deletion src/routes/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
use crate::common::WebAppData;
use crate::errors::{ServiceError, ServiceResult};
use crate::models::response::{OkResponse, TokenResponse};
use crate::routes::API_VERSION;
use crate::web::api::v1::contexts::user::forms::RegistrationForm;
use crate::web::api::API_VERSION;

pub fn init(cfg: &mut web::ServiceConfig) {
cfg.service(
Expand Down
2 changes: 1 addition & 1 deletion src/services/about.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Templates for "about" static pages.
use crate::routes::API_VERSION;
use crate::web::api::API_VERSION;

#[must_use]
pub fn index_page() -> String {
Expand Down
2 changes: 2 additions & 0 deletions src/web/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use tokio::task::JoinHandle;
use crate::common::AppData;
use crate::web::api;

pub const API_VERSION: &str = "v1";

/// API implementations.
pub enum Implementation {
/// API implementation with Actix Web.
Expand Down

0 comments on commit 9591239

Please sign in to comment.