mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew.git
synced 2025-05-13 11:37:33 -05:00
Add ability to specify protocol with command line argument
This commit is contained in:
parent
32b5f5b68c
commit
1cec98a01e
2 changed files with 10 additions and 6 deletions
|
@ -3,6 +3,8 @@ mod router;
|
|||
mod sql;
|
||||
use json::object;
|
||||
use actix_web::{
|
||||
App,
|
||||
HttpServer,
|
||||
get,
|
||||
HttpResponse,
|
||||
HttpRequest,
|
||||
|
@ -28,7 +30,6 @@ fn unhandled(req: HttpRequest, body: String) -> HttpResponse {
|
|||
}
|
||||
|
||||
async fn request(req: HttpRequest, body: String) -> HttpResponse {
|
||||
//let origbody = body.clone();
|
||||
if req.method() == "POST" {
|
||||
match req.path() {
|
||||
"/v1.0/auth/initialize" => router::gree::initialize(req, body),
|
||||
|
@ -138,12 +139,8 @@ async fn js(_req: HttpRequest) -> HttpResponse {
|
|||
.body(include_str!("../webui/dist/index.js"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
use actix_web::{App, HttpServer};
|
||||
|
||||
let rv = HttpServer::new(|| App::new()
|
||||
.wrap_fn(|req, srv| {
|
||||
println!("Request: {}", req.path());
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::router::global;
|
|||
use actix_web::{HttpResponse, HttpRequest, http::header::HeaderValue, http::header::ContentType, http::header::HeaderMap};
|
||||
use base64::{Engine as _, engine::general_purpose};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use sha1::Sha1;
|
||||
use substring::Substring;
|
||||
use json::{object, JsonValue};
|
||||
|
@ -335,6 +336,12 @@ pub fn migration_password_register(req: HttpRequest, body: String) -> HttpRespon
|
|||
send(req, resp)
|
||||
}
|
||||
|
||||
fn get_protocol() -> String {
|
||||
if env::args().nth(1).unwrap_or(String::new()) == String::from("https") {
|
||||
return String::from("https");
|
||||
}
|
||||
String::from("http")
|
||||
}
|
||||
|
||||
fn gree_authorize(req: &HttpRequest) -> String {
|
||||
type HmacSha1 = Hmac<Sha1>;
|
||||
|
@ -357,7 +364,7 @@ fn gree_authorize(req: &HttpRequest) -> String {
|
|||
}
|
||||
|
||||
let hostname = req.headers().get("host").unwrap_or(&blank_header).to_str().unwrap_or("");
|
||||
let current_url = format!("http://{}{}", hostname, req.path());
|
||||
let current_url = format!("{}://{}{}", get_protocol(), hostname, req.path());
|
||||
let uri = req.uri().to_string();
|
||||
let extra = if uri.contains("?") {
|
||||
format!("&{}", uri.split('?').nth(1).unwrap_or(""))
|
||||
|
|
Loading…
Add table
Reference in a new issue