Check if an email address exists without sending any email, written in Rust. Comes with a ⚙️ HTTP backend.
Rust emailemail-validationemail-validation-apiemail-verificationemail-verification-apiemail-verifierhacktoberfest
fix: Allow http to listen to $PORT env variable (#215)
Amaury Martiny3b0c262763bc
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.ymlindex 86627d37..4f6b408d 100644--- a/.github/workflows/deploy.yml+++ b/.github/workflows/deploy.yml@@ -87,8 +87,10 @@ jobs:# https://github.com/olegtarasov/get-tag- uses: olegtarasov/get-tag@v2- - name: Package- run: tar czf $CRATE_NAME-$GIT_TAG_NAME-$TARGET.tar.gz target/$TARGET/release/$BIN_NAME+ - name: Package into tar/zip+ run: |+ cp target/$TARGET/release/$BIN_NAME .+ tar czf $CRATE_NAME-$GIT_TAG_NAME-$TARGET.tar.gz $BIN_NAME# https://github.com/actions/create-release/issues/14#issuecomment-555379810- name: Load Release URL File from release jobdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 26c0585b..5e2bff81 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -2,10 +2,6 @@All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.-### [0.6.3](https://github.com/amaurymartiny/check_if_email_exists/compare/v0.6.2...v0.6.3) (2020-02-28)--### [0.6.2](https://github.com/amaurymartiny/check_if_email_exists/compare/v0.6.1...v0.6.2) (2020-02-28)-### [0.6.1](https://github.com/amaurymartiny/check_if_email_exists/compare/v0.6.0...v0.6.1) (2020-02-18)diff --git a/src/cli.yml b/src/cli.ymlindex de3da940..8f0cf29e 100644--- a/src/cli.yml+++ b/src/cli.yml@@ -1,28 +1,26 @@name: check_if_email_exists-version: "0.6.1"author: Amaury Martiny <[email protected]>about: Check if an email address exists without sending any email.args:- FROM_EMAIL:default_value: [email protected]long: from- help: The from email to use in the SMTP connection+ help: The from email to use in the SMTP connection.takes_value: true- HTTP:long: http- help: Runs a HTTP server+ help: Runs a HTTP server.- HTTP_HOST:default_value: "127.0.0.1"long: http-host- help: Sets the host IP address on which the HTTP server should bind. Only used when `--http` flag is on+ help: Sets the host IP address on which the HTTP server should bind. Only used when `--http` flag is on.takes_value: truevalue_name: HOST- HTTP_PORT:- default_value: "3000"long: http-port- help: Sets the port on which the HTTP server should bind. Only used when `--http` flag is on+ help: Sets the port on which the HTTP server should bind. Only used when `--http` flag is on. If not set, then it will use $PORT, or default to 3000.takes_value: truevalue_name: PORT- TO_EMAIL:- help: The email to check+ help: The email to check.index: 1diff --git a/src/main.rs b/src/main.rsindex 8f3475c0..f1d3b684 100644--- a/src/main.rs+++ b/src/main.rs@@ -24,8 +24,9 @@ extern crate tokio;mod http;use check_if_email_exists::email_exists;-use clap::App;+use clap::{crate_version, App};use serde_json;+use std::env;#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {@@ -33,7 +34,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {// The YAML file is found relative to the current file, similar to how modules are foundlet yaml = clap::load_yaml!("cli.yml");- let matches = App::from_yaml(yaml).get_matches();+ let matches = App::from_yaml(yaml).version(crate_version!()).get_matches();if let Some(to_email) = matches.value_of("TO_EMAIL") {let from_email = matches@@ -57,9 +58,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {let http_host = matches.value_of("HTTP_HOST").expect("HTTP_HOST has a default value. qed.");- let http_port = matches- .value_of("HTTP_PORT")- .expect("HTTP_PORT has a default value. qed.");+ // http_port is, in this order:+ // - the value of `--http-port` flag+ // - if not set, then the $PORT env varialbe+ // - if not set, then 3000+ let env_port = env::var("PORT").unwrap_or_else(|_| "3000".into());+ let http_port = matches.value_of("HTTP_PORT").unwrap_or(&env_port);http::run(http_host, http_port.parse::<u16>().unwrap()).await?}