deno.land / x / alosaur@v1.1.1 / examples / docker / areas / home / home.controller.ts

home.controller.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { ActionParam, Body, Content, Controller, Cookie, ForbiddenError, Get, Param, Post, QueryParam, Req, Res, Response, ServerRequest,} from "https://deno.land/x/alosaur/mod.ts";
@Controller("/home")export class HomeController { constructor() {} @Get("/text") @ActionParam(0, QueryParam("name")) @ActionParam(1, QueryParam("test")) @ActionParam(2, Cookie("username")) text( name: string, test: string, username: string, ) { return Content(`Hello world, ${name} ${test} ${username}`); } @Get("/json") @ActionParam(0, Req()) @ActionParam(1, Res()) @ActionParam(2, QueryParam("name")) json( request: ServerRequest, response: Response, name: string, ) { return Content(response); }
@Get("/error") error() { throw new ForbiddenError("error"); }
@Get("/test") gerTests() { return Content("test"); }
@Get("/test/:id") @ActionParam(0, Param("id")) gerParamId(id: string) { return Content(id); }
@Get("/test/:id/:name") @ActionParam(0, Param("id")) @ActionParam(1, Param("name")) gerParamIdName(id: string, name: string) { return Content(`${id} ${name}`); }
@Get("/test/:id/:name/detail") @ActionParam(0, Param("id")) @ActionParam(1, Param("name")) gerParamIdNameDetail(id: string, name: string) { return Content(`${id} ${name} detail`); } @Post("/post") @ActionParam(0, Body()) @ActionParam(1, QueryParam("name")) post(body: any, name: string) { return Content(body); }}
alosaur

Version Info

Tagged at
a year ago