This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //other code section goes here | |
| [dependencies] | |
| yew = "0.19" | |
| serde = { version = "1.0.145", features = ["derive"] } | |
| reqwest = { version = "0.11", features = ["json"] } | |
| wasm-bindgen-futures = "0.4" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use actix_web::{App, HttpServer}; //add | |
| use handlers::{send_otp, verify_otp}; //add | |
| mod handlers; | |
| mod models; | |
| mod services; | |
| //add | |
| #[actix_web::main] | |
| async fn main() -> std::io::Result<()> { | |
| HttpServer::new(move || App::new().service(send_otp).service(verify_otp)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use actix_web::{post, web::Json, HttpResponse}; | |
| use reqwest::StatusCode; | |
| use crate::{ | |
| models::{APIResponse, OTPData, VerifyOTPData}, | |
| services::TwilioService, | |
| }; | |
| #[post("/otp")] | |
| pub async fn send_otp(new_data: Json<OTPData>) -> HttpResponse { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //imports goes here | |
| pub struct TwilioService {} | |
| impl TwilioService { | |
| fn env_loader(key: &str) -> String { | |
| //code goes here | |
| } | |
| pub async fn send_otp(phone_number: &String) -> Result<OTPResponse, &'static str> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use std::{collections::HashMap, env}; | |
| use dotenv::dotenv; | |
| use reqwest::{header, Client}; | |
| use crate::models::{OTPResponse, OTPVerifyResponse}; | |
| pub struct TwilioService {} | |
| impl TwilioService { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use serde::{Deserialize, Serialize}; | |
| #[derive(Deserialize, Debug, Clone)] | |
| #[serde(rename_all = "camelCase")] | |
| pub struct OTPData { | |
| pub phone_number: String, | |
| } | |
| #[derive(Deserialize, Debug, Clone)] | |
| #[serde(rename_all = "camelCase")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| mod handlers; | |
| mod models; | |
| mod services; | |
| fn main() { | |
| println!("Hello, world!"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //other code section goes here | |
| [dependencies] | |
| actix-web = "4" | |
| serde = { version = "1.0.145", features = ["derive"] } | |
| dotenv = "0.15.0" | |
| reqwest = { version = "0.11", features = ["json"] } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "go-sms-verification/api" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| func main() { | |
| router := gin.Default() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package api | |
| import "github.com/gin-gonic/gin" | |
| type Config struct { | |
| Router *gin.Engine | |
| } | |
| //modify below | |
| func (app *Config) Routes() { |