update test example

This commit is contained in:
HorizonCode 2023-05-11 08:42:45 +02:00
parent 0f176fbe6b
commit 63be7aba60

View File

@ -2,6 +2,7 @@ import { Status } from "https://deno.land/std@0.186.0/http/http_status.ts";
import { HTTPServer } from "../http_server.ts";
const httpServer = new HTTPServer();
httpServer.add("GET", "/", (req, rep) => {
rep.status(Status.Teapot)
.header("working", "true")
@ -19,21 +20,24 @@ httpServer.add("GET", "/", (req, rep) => {
2,
);
});
httpServer.add("GET", "/api/user/:userId", (req, rep) => {
rep.status(Status.Teapot)
.type("application/json");
.type("application/json");
console.log(req.queryParams);
return JSON.stringify(
{
code: Status.Teapot,
message: `UserID is ${req.pathParams["userId"]}`,
message: `UserID is ${req.pathParam("userId")}`,
queryParams: req.queryParams,
},
null,
2,
);
});
httpServer.listen({
port: 8080,
staticLocalDir: "/static",