update test example
This commit is contained in:
parent
0f176fbe6b
commit
63be7aba60
|
@ -2,12 +2,13 @@ import { Status } from "https://deno.land/std@0.186.0/http/http_status.ts";
|
||||||
import { HTTPServer } from "../http_server.ts";
|
import { HTTPServer } from "../http_server.ts";
|
||||||
|
|
||||||
const httpServer = new HTTPServer();
|
const httpServer = new HTTPServer();
|
||||||
|
|
||||||
httpServer.add("GET", "/", (req, rep) => {
|
httpServer.add("GET", "/", (req, rep) => {
|
||||||
rep.status(Status.Teapot)
|
rep.status(Status.Teapot)
|
||||||
.header("working", "true")
|
.header("working", "true")
|
||||||
.type("application/json")
|
.type("application/json")
|
||||||
.cookie("working", "true");
|
.cookie("working", "true");
|
||||||
|
|
||||||
console.log(req.cookie("working"));
|
console.log(req.cookie("working"));
|
||||||
|
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
|
@ -19,21 +20,24 @@ httpServer.add("GET", "/", (req, rep) => {
|
||||||
2,
|
2,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
httpServer.add("GET", "/api/user/:userId", (req, rep) => {
|
httpServer.add("GET", "/api/user/:userId", (req, rep) => {
|
||||||
rep.status(Status.Teapot)
|
rep.status(Status.Teapot)
|
||||||
.type("application/json");
|
.type("application/json");
|
||||||
|
|
||||||
console.log(req.queryParams);
|
console.log(req.queryParams);
|
||||||
|
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
{
|
{
|
||||||
code: Status.Teapot,
|
code: Status.Teapot,
|
||||||
message: `UserID is ${req.pathParams["userId"]}`,
|
message: `UserID is ${req.pathParam("userId")}`,
|
||||||
|
queryParams: req.queryParams,
|
||||||
},
|
},
|
||||||
null,
|
null,
|
||||||
2,
|
2,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
httpServer.listen({
|
httpServer.listen({
|
||||||
port: 8080,
|
port: 8080,
|
||||||
staticLocalDir: "/static",
|
staticLocalDir: "/static",
|
||||||
|
|
Reference in New Issue
Block a user