Last active
January 18, 2021 15:49
-
-
Save netsi1964/2cca3408efba669dc1c0a07d4b37c3ad to your computer and use it in GitHub Desktop.
A deno script listning on port 8080 allowing to hit it with rest path: /:route/:id/:action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// deno run --allow-net mousse.ts | |
import { Mousse } from 'https://github.com/Tyrenn/mousse/raw/main/mod.ts'; | |
let mousse = new Mousse({ port: 8080 }); | |
async function handleRequest(c: any) { | |
const _body = { | |
...c.params, | |
}; | |
const body = JSON.stringify(_body); | |
c.response = { | |
status: 200, | |
'content-type': 'application/json', | |
body, | |
}; | |
} | |
mousse.get('/:route/:id/:action', handleRequest); | |
mousse.get('/:route/:id', handleRequest); | |
mousse.get('/:route', handleRequest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment