summaryrefslogtreecommitdiff
path: root/ext/flash/01_http.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-08-19 14:36:01 +0200
committerGitHub <noreply@github.com>2022-08-19 14:36:01 +0200
commit5beec3f106b0890cc76150d0e3b3661c576d4c3b (patch)
tree9692e24bdb5a7e1d1c883b91961cdacff3e6708c /ext/flash/01_http.js
parent1848c7e361f1a3a33487b60ab6fcb61ed1f62273 (diff)
feat(unstable): change Deno.serve() API (#15498)
- Merge "Deno.serve()" and "Deno.serveTls()" API - Remove first argument and use "fetch" field options instead - Update type declarations - Add more documentation
Diffstat (limited to 'ext/flash/01_http.js')
-rw-r--r--ext/flash/01_http.js26
1 files changed, 13 insertions, 13 deletions
diff --git a/ext/flash/01_http.js b/ext/flash/01_http.js
index 19920da58..d850a1520 100644
--- a/ext/flash/01_http.js
+++ b/ext/flash/01_http.js
@@ -185,18 +185,19 @@
return hostname === "0.0.0.0" ? "localhost" : hostname;
}
- function serve(handler, opts = {}) {
- delete opts.key;
- delete opts.cert;
- return serveInner(handler, opts, false);
- }
-
- function serveTls(handler, opts = {}) {
- return serveInner(handler, opts, true);
- }
-
- function serveInner(handler, opts, useTls) {
- opts = { hostname: "127.0.0.1", port: 9000, useTls, ...opts };
+ function serve(opts = {}) {
+ if (!("fetch" in opts)) {
+ throw new TypeError("Options is missing 'fetch' handler");
+ }
+ if ("cert" in opts && !("key" in opts)) {
+ throw new TypeError("Options is missing 'key' field");
+ }
+ if ("key" in opts && !("cert" in opts)) {
+ throw new TypeError("Options is missing 'cert' field");
+ }
+ opts = { hostname: "127.0.0.1", port: 9000, ...opts };
+ const handler = opts.fetch;
+ delete opts.fetch;
const signal = opts.signal;
delete opts.signal;
const onError = opts.onError ?? function (error) {
@@ -570,6 +571,5 @@
window.__bootstrap.flash = {
serve,
- serveTls,
};
})(this);