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"; 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")
@ -19,6 +20,7 @@ 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");
@ -28,12 +30,14 @@ httpServer.add("GET", "/api/user/:userId", (req, rep) => {
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",