Skip to content

Commit 651bcbe

Browse files
Expanded type support
1 parent 46474e2 commit 651bcbe

4 files changed

Lines changed: 7 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ happy_birthday.py
2828

2929

3030
@hug.get('/happy_birthday')
31-
def happy_birthday(name, age:int, **kwargs):
31+
def happy_birthday(name, age:hug.types.int, **kwargs):
3232
"""Says happy birthday to a user"""
3333
return "Happy {age} Birthday {name}!".format(**locals())
3434

@@ -46,10 +46,12 @@ versioning_example.py
4646

4747
"""A simple example of a hug API call with versioning"""
4848

49+
4950
@hug.version[1].get('/echo')
5051
def echo(text, **kwargs):
5152
return text
5253

54+
5355
@hug.version[2:].get('/echo')
5456
def echo(text, **kwargs):
5557
return "Echo: {text}".format(**locals())

examples/happy_birthday.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44

55
@hug.get('/happy_birthday')
6-
def happy_birthday(name, age:int, **kwargs):
6+
def happy_birthday(name, age:hug.types.number, **kwargs):
77
"""Says happy birthday to a user"""
88
return "Happy {age} Birthday {name}!".format(**locals())

examples/versioning.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""A simple example of a hug API call with versioning"""
22

3+
34
@hug.version[1].get('/echo')
45
def echo(text, **kwargs):
56
return text
67

8+
79
@hug.version[2:].get('/echo')
810
def echo(text, **kwargs):
911
return "Echo: {text}".format(**locals())

hug/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
from hug.decorators import call, get, post, put, delete
3131
from hug import run
3232
from hug.run import terminal
33+
from hug import types
3334

3435
__version__ = "0.0.1"

0 commit comments

Comments
 (0)