Created
March 18, 2016 08:01
-
-
Save timothycrosley/a26a02569396f658bc9f to your computer and use it in GitHub Desktop.
Class based routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hug | |
# As a pattern for reuse | |
@hug.object.urls('/endpoint', requires=()) | |
class MyClass(object): | |
@hug.object.get() | |
def my_method(self): | |
return 'hi there!' | |
@hug.object.post() | |
def my_method_two(self): | |
return 'bye' | |
# Or, just a way to group related functionality | |
@hug.object.http_methods() | |
class Contact(object): | |
def get(self): | |
return 'retrieving contact' | |
def post(self): | |
return 'creating contact' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment