fix main.rs routes
This commit is contained in:
parent
5f1410fb2f
commit
2293666c1f
1 changed files with 9 additions and 6 deletions
15
src/main.rs
15
src/main.rs
|
@ -1,15 +1,10 @@
|
|||
use actix_cors::Cors;
|
||||
use actix_files::Files;
|
||||
use actix_web::{middleware::DefaultHeaders, web, App, HttpServer};
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use anyhow::Result;
|
||||
use simplelink::{handlers, AppState};
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
use tracing::info;
|
||||
|
||||
async fn index() -> Result<actix_files::NamedFile, actix_web::Error> {
|
||||
Ok(actix_files::NamedFile::open("./static/index.html")?)
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> Result<()> {
|
||||
// Load environment variables from .env file
|
||||
|
@ -53,6 +48,14 @@ async fn main() -> Result<()> {
|
|||
.route("/shorten", web::post().to(handlers::create_short_url))
|
||||
.route("/links", web::get().to(handlers::get_all_links))
|
||||
.route("/links/{id}", web::delete().to(handlers::delete_link))
|
||||
.route(
|
||||
"/links/{id}/clicks",
|
||||
web::get().to(handlers::get_link_clicks),
|
||||
)
|
||||
.route(
|
||||
"/links/{id}/sources",
|
||||
web::get().to(handlers::get_link_sources),
|
||||
)
|
||||
.route("/auth/register", web::post().to(handlers::register))
|
||||
.route("/auth/login", web::post().to(handlers::login))
|
||||
.route("/health", web::get().to(handlers::health_check)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue