src/happyx/routing/decorators

Search:
Group by:

Decorators 🔌

Provides convenient wrapper to create route decorators

It can be used for plugins also

Decorator Usage Example ✨

serve ...:
  @AuthBasic
  get "/":
    # password and username takes from header "Authorization"
    # Authorization: Bearer BASE64
    echo username
    echo password

Own decorators

proc myDecorator(httpMethods: seq[string], routePath: string, statementList: NimNode) =
  statementList.insert(0, newCall("echo", newLit"My own decorator"))
# Register decorator
static:
  regDecorator("MyDecorator", myDecorator)
# Use it
serve ...:
  @MyDecorator
  get "/":