Created
May 14, 2020 14:38
-
-
Save hackedd/3443c8f176f9c451e6250b184d55b378 to your computer and use it in GitHub Desktop.
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 falcon | |
import falcon_cors | |
class Resource: | |
def on_get(self, req, resp): | |
resp.media = {"status": 200} | |
on_post = on_get | |
class ResourceWithSuffix: | |
def on_get_suffix(self, req, resp): | |
resp.media = {"status": 200} | |
on_post_suffix = on_get_suffix | |
cors = falcon_cors.CORS( | |
allow_all_origins=True, | |
allow_all_methods=True, | |
allow_all_headers=True, | |
) | |
app = falcon.API(middleware=[cors.middleware]) | |
resource = Resource() | |
app.add_route("/a", resource) | |
resource_with_suffix = ResourceWithSuffix() | |
app.add_route("/b", resource_with_suffix, suffix="suffix") | |
# To illustrate the problem: | |
print("Without:", cors._get_resource_methods(resource)) | |
print("With suffix:", cors._get_resource_methods(resource_with_suffix)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment