-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SFR-2419: Deprecate singular noun endpoints (#493)
* add deprecation warning header for singular noun endpoints * fix linting error * add check for response type
- Loading branch information
1 parent
b9c2b63
commit 2973981
Showing
5 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from functools import wraps | ||
from logger import create_log | ||
import logging | ||
|
||
logger = create_log(__name__) | ||
|
||
|
||
def deprecated(message): | ||
def decorator(func): | ||
@wraps(func) | ||
def wrapper(*args, **kwargs): | ||
resp = func(*args, **kwargs) | ||
return warn_deprecated(resp, message) | ||
return wrapper | ||
return decorator | ||
|
||
def warn_deprecated(response, message): | ||
if isinstance(response, tuple): | ||
response[0].headers['Warning'] = message | ||
logger.warning(message) | ||
return response |