✖
Terrarium に Terrarium を Terrarium する Terrarium
ほんとは自分自身を deploy するやつを deploy したかったんだけどやめた。やる気が失せたので書いたところだけ記録しておく。
#[macro_use]
extern crate http_guest;
extern crate http;
// #[macro_use]
// extern crate failure;
extern crate serde;
#[macro_use]
extern crate serde_json;
//#[macro_use]
//extern crate serde_derive;
use std::fmt;
use http_guest::{Request, RequestExt, Response, KVStore};
use serde_json::Value;
pub fn user_entrypoint(kvs: &mut KVStore, req: &Request<Vec<u8>>) -> Response<Vec<u8>> {
if req.uri() != "/" {
return Response::builder()
.status(404)
.body("".as_bytes().to_owned())
.unwrap()
}
let body_json = json!({
"lang": "rust",
"options": "",
"tar": "c3JjL2xpYi5ycwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAwMDA3NzcAMDAwMDAwMAAwMDAwMDAwADAwMDAwMDAwNDUwADEzNDU2MzQ2MzMwADAwNzY2NAAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB1c3RhciAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==="
});
let request = Request::builder()
.method("POST")
.uri("https://wasm.fastlylabs.com/deploy")
.header("Content-Type", "application/json")
.body(body_json.to_string().as_bytes().to_owned())
.unwrap();
let response = request.send().unwrap();
if response.status() == 200 {
let resp_body: &[u8] = &response.body();
let json: Value = serde_json::from_slice(resp_body).unwrap();
let body = format!("deployed: https://{}.fastly-terrarium.com/",
json["id"].as_str().unwrap()
);
return Response::builder()
.status(200)
.header("Content-Type", "text/plain")
.body(body.as_bytes().to_owned())
.unwrap();
}
let body = format!("failed to deploy");
return Response::builder()
.status(200)
.header("Content-Type", "text/plain")
.body(body.as_bytes().to_owned())
.unwrap();
}
guest_app_kvs!(user_entrypoint);
Ruby で書いたデプロイスクリプト
いきなり Rust で書きくだせるほど Rust に慣れていないので、Ruby で前哨戦をしていた。こっちはちゃんと deploy が終わるまで待つ。
#!/usr/bin/env ruby
require "uri"
require "net/https"
require 'json'
uri = URI.parse('https://wasm.fastlylabs.com/deploy')
req = Net::HTTP::Post.new(uri.request_uri)
req["Content-Type"] = "application/json"
req.body = ({
lang: "rust",
options: "",
tar: File.read("./foo.tar.base64")
}).to_json
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
res = http.request(req)
p res
dat = JSON.parse(res.body)
p dat
loop do
status_uri = "https://wasm.fastlylabs.com/status/%s" % dat["id"]
res = http.request(Net::HTTP::Get.new(URI.parse(status_uri).request_uri))
data = JSON.parse(res.body)
p data
if data["status"] == "deployed"
break
end
sleep 1
end
puts "https://%s.fastly-terrarium.com/" % dat["id"]