This gist demonstrates how to implement a expressjs-style middleware design with Chain of Responsibility design pattern.
expressjs middleware has the following structure
app.use((req, res, next) => {
...
next();
{ | |
"type": "object", | |
"properties": { | |
"name": { | |
"type": "string" | |
}, | |
"version": { | |
"type": "string" | |
}, | |
"description": { |
[package] | |
name = "axum-tonic" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
tonic = "0.11" | |
prost = "0.12" | |
tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } |
[package] | |
name = "rust_http_file_upload" | |
version = "0.1.0" | |
edition = "2021" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
actix = "0.13.1" | |
actix-multipart = "0.6.1" |
{} |
{ | |
"version": "0.1.8", | |
"notes": "See the assets to download this version and install.", | |
"pub_date": "2023-06-13T05:12:10.282Z", | |
"platforms": { | |
"linux-x86_64": { | |
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVRQlFBRHprQnQ1Qm1GZUpQcFBxTGJtbER3cWlmKzVPbUNMQlFNSXQ0TVQ2V0RSMVkzY1JNc0YvWGh5Y0FpZXlQY25TRXNrU0ErV0xCUjMyTmloUVR2dXZCMzBZK0hBTWdJPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNjg2NjMyMDk3CWZpbGU6ZXotdXBfMC4xLjhfYW1kNjQuQXBwSW1hZ2UudGFyLmd6CnZ6ZHBkall4TnZhUlpieXUyMUZZTFBqRGJhVXpGVzFFUGFwcDByS3VQb0xrUE9uNWEzWEY0RGppRGQ4c3lpWlZvL3R6MHVGYkZjNjJmbnVmb3VWZ0RRPT0K", | |
"url": "https://github.com/HuakunShen/EzUp/releases/download/v0.1.8/ez-up_0.1.8_amd64.AppImage.tar.gz" | |
}, | |
"windows-x86_64": { |
{ | |
"version": "0.1.6", | |
"notes": "See the assets to download this version and install.", | |
"pub_date": "2023-06-13T02:44:18.071Z", | |
"platforms": { | |
"linux-x86_64": { | |
"signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIHRhdXJpIHNlY3JldCBrZXkKUlVTbU5XTmtNQkU1NDlIWkw4SHN2em5OQTBxVm90eFNsYUZQeDhMckRteUQ1dndDR01sa3FzbG9KSDNmVmZTenNrdUoyRGh5Z21pcGVDT0cvdEpJWEFHTXV2ejY1QVp5alFVPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNjg2NjIzMzkwCWZpbGU6d29ybWhvbGUtZ3VpXzAuMS42X2FtZDY0LkFwcEltYWdlLnRhci5negpzUGh2Q2dTZU01Q0pZQlVnUWo1MkxROFJvYTU2WjA0dUl3ZUROTWJEYW4zUGFDdUdQZXJXRmY3c1Y4Z0pkNlJ5aWpIaGlLQmNmeHErQWZBSVhvUVNEUT09Cg==", | |
"url": "https://github.com/HuakunShen/wormhole-gui/releases/download/v0.1.6/wormhole-gui_0.1.6_amd64.AppImage.tar.gz" | |
}, | |
"windows-x86_64": { |
#!/bin/bash | |
cwd=$PWD | |
submodulePaths=$(git submodule | awk '{$1=$1;print}' | cut -d ' ' -f 2) | |
function git_add_commit_update { | |
nothing=$(git status | grep 'nothing to commit') | |
if [[ -z $nothing ]]; then | |
git add . |
// cargo add image | |
// cargo add arboard | |
use std::convert::TryInto; | |
use arboard::*; | |
use image::*; | |
fn main() { | |
let mut clipboard = Clipboard::new().unwrap(); | |
let image = match clipboard.get_image() { |
import fs from 'node:fs'; | |
const imagePath = '000000.jpg'; | |
const encode = 'base64'; | |
const rawImgBuf = fs.readFileSync(imagePath); | |
const encodedStr = rawImgBuf.toString(encode); | |
const recoveredBuf = Buffer.from(encodedStr, encode); | |
fs.writeFileSync('test.jpg', recoveredBuf); | |