October 2019
Intermediate to advanced
444 pages
10h 37m
English
Let's build an API with a few steps:
#[macro_use]extern crate actix_web;use actix_files as fs;use actix_web::{ guard, http::header, http::Method, middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder, Result,};use std::env;use std::path::PathBuf;
#[get("by-id/{id}")]fn bookmark_by_id(id: web::Path<(i32)>) -> impl Responder { format!("{{ \"id\": {}, \"url\": \"https://blog.x5ff.xyz\" }}", id)}fn echo_bookmark(req: HttpRequest) -> impl Responder { let id: i32 = req.match_info().query("id").parse().unwrap(); ...