切换为 goja
This commit is contained in:
8
examples/JS/.pages.yaml
Normal file
8
examples/JS/.pages.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
routes:
|
||||
- path: "api/dev/**"
|
||||
js:
|
||||
exec: "index.js"
|
||||
debug: true
|
||||
- path: "api/prod/**"
|
||||
js:
|
||||
exec: "json.js"
|
||||
13
examples/JS/index.html
Normal file
13
examples/JS/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>JS 概念验证</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
7
examples/JS/index.js
Normal file
7
examples/JS/index.js
Normal file
@@ -0,0 +1,7 @@
|
||||
response.write("hello world")
|
||||
console.log("hello world")
|
||||
function testError(){
|
||||
throw Error("Method not implemented")
|
||||
}
|
||||
response.setHeader("content-type", "application/json")
|
||||
testError()
|
||||
4
examples/JS/json.js
Normal file
4
examples/JS/json.js
Normal file
@@ -0,0 +1,4 @@
|
||||
resp.setHeader("content-type", "application/json");
|
||||
resp.write(JSON.stringify({
|
||||
'method': req.method,
|
||||
}))
|
||||
Reference in New Issue
Block a user