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 "/":
Types
DecoratorImpl = proc (httpMethods: seq[string]; routePath: string; statementList: NimNode; arguments: seq[NimNode])
Vars
decorators {.compileTime.} = newTable(32)
Procs
proc regDecorator(decoratorName: string; decorator: DecoratorImpl) {. compileTime, ...raises: [], tags: [], forbids: [].}