useanyhow::Result;usehttp::{Method,StatusCode};usespin_sdk::{http::{Request,Response},http_component,key_value::{Error,Store},};#[http_component]fnhandle_request(req: Request)-> Result<Response>{// Open the default key-value storeletstore=Store::open_default()?;let(status,body)=matchreq.method(){&Method::POST=>{// Add the request (URI, body) tuple to the storestore.set(req.uri().path(),req.body().as_deref().unwrap_or(&[]))?;(StatusCode::OK,None)}&Method::GET=>{// Get the value associated with the request URI, or return a 404 if it's not presentmatchstore.get(req.uri().path()){Ok(value)=>(StatusCode::OK,Some(value.into())),Err(Error::NoSuchKey)=>(StatusCode::NOT_FOUND,None),Err(error)=>returnErr(error.into()),}}&Method::DELETE=>{// Delete the value associated with the request URI, if presentstore.delete(req.uri().path())?;(StatusCode::OK,None)}&Method::HEAD=>{// Like GET, except do not return the valuematchstore.exists(req.uri().path()){Ok(true)=>(StatusCode::OK,None),Ok(false)=>(StatusCode::NOT_FOUND,None),Err(error)=>returnErr(error.into()),}}// No other methods are currently supported_=>(StatusCode::METHOD_NOT_ALLOWED,None),};Ok(http::Response::builder().status(status).body(body)?)}