Run server on expected port (5050 or custom)
This commit is contained in:
parent
ed2ae20951
commit
cba28e8e2c
3 changed files with 8 additions and 4 deletions
|
@ -30,6 +30,7 @@ error_chain! {
|
||||||
Time(std::time::SystemTimeError);
|
Time(std::time::SystemTimeError);
|
||||||
Toml(toml::de::Error);
|
Toml(toml::de::Error);
|
||||||
Regex(regex::Error);
|
Regex(regex::Error);
|
||||||
|
RocketConfig(rocket::config::ConfigError);
|
||||||
Scrobbler(rustfm_scrobble::ScrobblerError);
|
Scrobbler(rustfm_scrobble::ScrobblerError);
|
||||||
Vorbis(lewton::VorbisError);
|
Vorbis(lewton::VorbisError);
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,10 +235,13 @@ fn run() -> Result<()> {
|
||||||
.parse()
|
.parse()
|
||||||
.or(Err("invalid port number"))?;
|
.or(Err("invalid port number"))?;
|
||||||
|
|
||||||
// TODO Use port number
|
let config = rocket::Config::build(rocket::config::Environment::Production)
|
||||||
|
.port(port)
|
||||||
|
.finalize()?;
|
||||||
|
|
||||||
let db_server = db.clone();
|
let db_server = db.clone();
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
rocket::ignite()
|
rocket::custom(config)
|
||||||
.manage(db_server)
|
.manage(db_server)
|
||||||
.manage(command_sender)
|
.manage(command_sender)
|
||||||
.mount(&static_url, StaticFiles::from(web_dir_path))
|
.mount(&static_url, StaticFiles::from(web_dir_path))
|
||||||
|
|
|
@ -82,11 +82,11 @@ impl<'a, 'r> FromRequest<'a, 'r> for Auth {
|
||||||
if let Ok(Basic {
|
if let Ok(Basic {
|
||||||
username,
|
username,
|
||||||
password: Some(password),
|
password: Some(password),
|
||||||
}) = Basic::from_str(auth_header_string.trim_start_matches("Basic ")) // Sadness
|
}) = Basic::from_str(auth_header_string.trim_start_matches("Basic "))
|
||||||
{
|
{
|
||||||
let db = match request.guard::<State<Arc<DB>>>() {
|
let db = match request.guard::<State<Arc<DB>>>() {
|
||||||
Outcome::Success(d) => d,
|
Outcome::Success(d) => d,
|
||||||
_ => return Outcome::Failure((Status::InternalServerError, ()))
|
_ => return Outcome::Failure((Status::InternalServerError, ())),
|
||||||
};
|
};
|
||||||
if user::auth(db.deref().deref(), &username, &password).unwrap_or(false) {
|
if user::auth(db.deref().deref(), &username, &password).unwrap_or(false) {
|
||||||
cookies.add_private(get_auth_cookie(&username));
|
cookies.add_private(get_auth_cookie(&username));
|
||||||
|
|
Loading…
Add table
Reference in a new issue