forked from HapticX/happyx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testc19.nim
60 lines (46 loc) · 1.07 KB
/
testc19.nim
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
import ../src/happyx
echo genSessionId()
model User:
username: string
id: int
model News:
id: int
title: string
description: string = ""
serve "127.0.0.1", 5000:
var sessionId: string = ""
get "/":
## Opens or loads a new session with timeout 10 seconds
##
## @openapi {
## operationId = startSession
## summary = Открыть сессию
##
## @params {
## username : integer - юзернейм пользователя
## }
## }
var session = startSession(10) # in seconds
sessionId = session.id
return session.id
get "/user{userId:int}":
## Shows user at ID {id}
##
## @openapi {
## operationId = getUserById
## summary = Профиль
## }
return fmt"Hello, {userId}"
post "/user[u:User]":
return 0
post "/news[n:News]":
return 0
get "/close":
## Closes current session
##
## @openapi {
## operationId = closeSession
## summary = Закрыть сессию
## }
closeSession(sessionId)
return {"response": "success"}