3535 MissingValueError * = object of ValueError # # Indicates an error associated with Cookie.
3636
3737
38- proc initCookie * (name, value: string , expires = " " , maxAge: Option [int ] = none (int ),
39- domain = " " , path = " " ,
40- secure = false , httpOnly = false , sameSite = Lax ): Cookie {.inline .} =
41- # # Initiates Cookie object.
38+ func initCookie * (
39+ name, value: string , expires = " " , maxAge = none (int ),
40+ domain = " " , path = " " , secure = false ,
41+ httpOnly = false , sameSite = Lax
42+ ): Cookie {.inline .} =
43+ # # Initiates a `Cookie` object.
4244 runnableExamples:
4345 let
4446 username = " admin"
@@ -52,10 +54,12 @@ proc initCookie*(name, value: string, expires = "", maxAge: Option[int] = none(i
5254 maxAge: maxAge, domain: domain, path: path,
5355 secure: secure, httpOnly: httpOnly, sameSite: sameSite)
5456
55- proc initCookie * (name, value: string , expires: DateTime | Time ,
56- maxAge: Option [int ] = none (int ), domain = " " , path = " " , secure = false , httpOnly = false ,
57- sameSite = Lax ): Cookie {.inline .} =
58- # # Initiates Cookie object.
57+ func initCookie * (
58+ name, value: string , expires: DateTime | Time ,
59+ maxAge = none (int ), domain = " " , path = " " ,
60+ secure = false , httpOnly = false , sameSite = Lax
61+ ): Cookie {.inline .} =
62+ # # Initiates a `Cookie` object.
5963 runnableExamples:
6064 import times
6165
@@ -73,7 +77,7 @@ proc initCookie*(name, value: string, expires: DateTime|Time,
7377 " ddd',' dd MMM yyyy HH:mm:ss 'GMT'" ), maxAge, domain, path, secure,
7478 httpOnly, sameSite)
7579
76- proc parseParams (cookie: var Cookie , key: string , value: string ) {. inline .} =
80+ func parseParams (cookie: var Cookie , key: string , value: string ) =
7781 # # Parse Cookie attributes from key-value pairs.
7882 case key.toLowerAscii
7983 of " expires" :
@@ -105,7 +109,7 @@ proc parseParams(cookie: var Cookie, key: string, value: string) {.inline.} =
105109 else :
106110 discard
107111
108- proc initCookie * (text: string ): Cookie {. inline .} =
112+ func initCookie * (text: string ): Cookie =
109113 # # Initiates Cookie object from strings.
110114 runnableExamples:
111115 doAssert initCookie (" foo=bar=baz" ).name == " foo"
@@ -144,7 +148,7 @@ proc initCookie*(text: string): Cookie {.inline.} =
144148 break
145149 inc (pos) # skip ';
146150
147- proc setCookie * (cookie: Cookie ): string =
151+ func setCookie * (cookie: Cookie ): string =
148152 # # Stringifys Cookie object to get Set-Cookie HTTP response headers.
149153 runnableExamples:
150154 import strformat
@@ -173,7 +177,7 @@ proc setCookie*(cookie: Cookie): string =
173177 if cookie.sameSite != None :
174178 result .add (" ; SameSite=" & $ cookie.sameSite)
175179
176- proc `$` * (cookie: Cookie ): string {.inline .} =
180+ func `$` * (cookie: Cookie ): string {.inline .} =
177181 # # Stringifys Cookie object to get Set-Cookie HTTP response headers.
178182 runnableExamples:
179183 import strformat
@@ -188,39 +192,39 @@ proc `$`*(cookie: Cookie): string {.inline.} =
188192
189193 setCookie (cookie)
190194
191- proc initCookieJar * (): CookieJar {.inline .} =
195+ func initCookieJar * (): CookieJar {.inline .} =
192196 # # Creates a new cookieJar that is empty.
193197 CookieJar (data: newStringTable (mode = modeCaseSensitive))
194198
195- proc len * (cookieJar: CookieJar ): int {.inline .} =
199+ func len * (cookieJar: CookieJar ): int {.inline .} =
196200 # # Returns the number of names in ``cookieJar``.
197201 cookieJar.data.len
198202
199- proc `[]` * (cookieJar: CookieJar , name: string ): string {.inline .} =
203+ func `[]` * (cookieJar: CookieJar , name: string ): string {.inline .} =
200204 # # Retrieves the value at ``cookieJar[name]``.
201205 # #
202206 # # If ``name`` is not in ``cookieJar``, the ``KeyError`` exception is raised.
203207 cookieJar.data[name]
204208
205- proc getOrDefault * (cookieJar: CookieJar , name: string , default = " " ): string {.inline .} =
209+ func getOrDefault * (cookieJar: CookieJar , name: string , default = " " ): string {.inline .} =
206210 # # Retrieves the value at ``cookieJar[name]`` if ``name`` is in ``cookieJar``. Otherwise, the
207211 # # default value is returned(default is "").
208212 cookieJar.data.getOrDefault (name, default)
209213
210- proc hasKey * (cookieJar: CookieJar , name: string ): bool {.inline .} =
214+ func hasKey * (cookieJar: CookieJar , name: string ): bool {.inline .} =
211215 # # Returns true if ``name`` is in the ``cookieJar``.
212216 cookieJar.data.hasKey (name)
213217
214- proc contains * (cookieJar: CookieJar , name: string ): bool {.inline .} =
218+ func contains * (cookieJar: CookieJar , name: string ): bool {.inline .} =
215219 # # Returns true if ``name`` is in the ``cookieJar``.
216220 # # Alias of ``hasKey`` for use with the ``in`` operator.
217221 cookieJar.data.contains (name)
218222
219- proc `[]=` * (cookieJar: var CookieJar , name: string , value: string ) {.inline .} =
223+ func `[]=` * (cookieJar: var CookieJar , name: string , value: string ) {.inline .} =
220224 # # Inserts a ``(name, value)`` pair into ``cookieJar``.
221225 cookieJar.data[name] = value
222226
223- proc parse * (cookieJar: var CookieJar , text: string ) {.inline .} =
227+ func parse * (cookieJar: var CookieJar , text: string ) {.inline .} =
224228 # # Parses CookieJar from strings.
225229 runnableExamples:
226230 var cookieJar = initCookieJar ()
0 commit comments