+9
-6
src/main.rs
+9
-6
src/main.rs
···
1
use actix_cors::Cors;
2
-
use actix_files::Files;
3
-
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
4
use anyhow::Result;
5
use simplelink::{handlers, AppState};
6
use sqlx::postgres::PgPoolOptions;
7
use tracing::info;
8
-
9
-
async fn index() -> Result<actix_files::NamedFile, actix_web::Error> {
10
-
Ok(actix_files::NamedFile::open("./static/index.html")?)
11
-
}
12
13
#[actix_web::main]
14
async fn main() -> Result<()> {
···
53
.route("/shorten", web::post().to(handlers::create_short_url))
54
.route("/links", web::get().to(handlers::get_all_links))
55
.route("/links/{id}", web::delete().to(handlers::delete_link))
56
.route("/auth/register", web::post().to(handlers::register))
57
.route("/auth/login", web::post().to(handlers::login))
58
.route("/health", web::get().to(handlers::health_check)),
···
1
use actix_cors::Cors;
2
+
use actix_web::{web, App, HttpServer};
3
use anyhow::Result;
4
use simplelink::{handlers, AppState};
5
use sqlx::postgres::PgPoolOptions;
6
use tracing::info;
7
8
#[actix_web::main]
9
async fn main() -> Result<()> {
···
48
.route("/shorten", web::post().to(handlers::create_short_url))
49
.route("/links", web::get().to(handlers::get_all_links))
50
.route("/links/{id}", web::delete().to(handlers::delete_link))
51
+
.route(
52
+
"/links/{id}/clicks",
53
+
web::get().to(handlers::get_link_clicks),
54
+
)
55
+
.route(
56
+
"/links/{id}/sources",
57
+
web::get().to(handlers::get_link_sources),
58
+
)
59
.route("/auth/register", web::post().to(handlers::register))
60
.route("/auth/login", web::post().to(handlers::login))
61
.route("/health", web::get().to(handlers::health_check)),