Skip to content

Instantly share code, notes, and snippets.

View Mr-Malomz's full-sized avatar

Demola Malomo Mr-Malomz

  • Lagos, Nigeria
View GitHub Profile
//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"
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))
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 {
//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> {
use std::{collections::HashMap, env};
use dotenv::dotenv;
use reqwest::{header, Client};
use crate::models::{OTPResponse, OTPVerifyResponse};
pub struct TwilioService {}
impl TwilioService {
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")]
mod handlers;
mod models;
mod services;
fn main() {
println!("Hello, world!");
}
//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"] }
package main
import (
"go-sms-verification/api"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
package api
import "github.com/gin-gonic/gin"
type Config struct {
Router *gin.Engine
}
//modify below
func (app *Config) Routes() {