Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
itsumura-h committed Feb 16, 2024
1 parent 81acc2e commit a38ddab
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
8 changes: 4 additions & 4 deletions src/basolato/core/base.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import std/httpcore
# import std/httpcore

const
BasolatoVersion* = "0.15.0"
Expand Down Expand Up @@ -47,9 +47,9 @@ type
ErrorHttpParse* = object of CatchableError
DD* = object of CatchableError

const errorStatusArray* = [505, 504, 503, 502, 501, 500, 451, 431, 429, 428, 426,
422, 421, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406,
405, 404, 403, 401, 400, 307, 305, 304, 303, 302, 301, 300]
# const errorStatusArray* = [505, 504, 503, 502, 501, 500, 451, 431, 429, 428, 426,
# 422, 421, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406,
# 405, 404, 403, 401, 400, 307, 305, 304, 303, 302, 301, 300]


when not defined(release):
Expand Down
66 changes: 33 additions & 33 deletions src/basolato/core/route.nim
Original file line number Diff line number Diff line change
Expand Up @@ -244,39 +244,39 @@ proc createResponse*(req:Request, route:Route, httpMethod:HttpMethod, context:Co
return response2


const errorStatusArray* = [505, 504, 503, 502, 501, 500, 451, 431, 429, 428, 426,
422, 421, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406,
405, 404, 403, 401, 400, 307, 305, 304, 303, 302, 301, 300]


macro createHttpCodeError():untyped =
var strBody = ""
for num in errorStatusArray:
strBody.add(fmt"""
of "Error{num.repr}":
return Http{num.repr}
""")
return parseStmt(fmt"""
case $exception.name
{strBody}
else:
return Http400
""")

func checkHttpCode*(exception:ref Exception):HttpCode =
## Generated by macro createHttpCodeError.
## List is httpCodeArray
## .. code-block:: nim
## case $exception.name
## of Error505:
## return Http505
## of Error504:
## return Http504
## of Error503:
## return Http503
## .
## .
createHttpCodeError
# const errorStatusArray* = [505, 504, 503, 502, 501, 500, 451, 431, 429, 428, 426,
# 422, 421, 418, 417, 416, 415, 414, 413, 412, 411, 410, 409, 408, 407, 406,
# 405, 404, 403, 401, 400, 307, 305, 304, 303, 302, 301, 300]


# macro createHttpCodeError():untyped =
# var strBody = ""
# for num in errorStatusArray:
# strBody.add(fmt"""
# of "Error{num.repr}":
# return Http{num.repr}
# """)
# return parseStmt(fmt"""
# case $exception.name
# {strBody}
# else:
# return Http400
# """)

# func checkHttpCode*(exception:ref Exception):HttpCode =
# ## Generated by macro createHttpCodeError.
# ## List is httpCodeArray
# ## .. code-block:: nim
# ## case $exception.name
# ## of Error505:
# ## return Http505
# ## of Error504:
# ## return Http504
# ## of Error503:
# ## return Http503
# ## .
# ## .
# createHttpCodeError

proc doesRunAnonymousLogin*(req:Request, res:Response):bool =
if not ENABLE_ANONYMOUS_COOKIE:
Expand Down

0 comments on commit a38ddab

Please sign in to comment.