You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2020/01/24 18:55:30 UTC
[trafficcontrol] branch master updated: Added deprecation notice to
/hwinfo/dtdata (#4331)
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new ce22bca Added deprecation notice to /hwinfo/dtdata (#4331)
ce22bca is described below
commit ce22bcab65b2a97650bf19af365387efd5d107b0
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Fri Jan 24 11:55:18 2020 -0700
Added deprecation notice to /hwinfo/dtdata (#4331)
---
traffic_ops/app/lib/API/HwInfo.pm | 2 +-
traffic_ops/app/lib/MojoPlugins/Response.pm | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/traffic_ops/app/lib/API/HwInfo.pm b/traffic_ops/app/lib/API/HwInfo.pm
index 15ef143..602706e 100644
--- a/traffic_ops/app/lib/API/HwInfo.pm
+++ b/traffic_ops/app/lib/API/HwInfo.pm
@@ -119,7 +119,7 @@ sub data {
my %itotal_records = ( iTotalDisplayRecords => $total_records );
%data = %{ merge( \%data, \%itotal_records ) };
- $self->render( json => \%data );
+ $self->deprecation_with_no_alternative(200, json => \%data );
}
1;
diff --git a/traffic_ops/app/lib/MojoPlugins/Response.pm b/traffic_ops/app/lib/MojoPlugins/Response.pm
index 977121a..d636ab5 100644
--- a/traffic_ops/app/lib/MojoPlugins/Response.pm
+++ b/traffic_ops/app/lib/MojoPlugins/Response.pm
@@ -170,6 +170,23 @@ sub register {
}
);
+ $app->renderer->add_helper(
+ deprecation_with_no_alternative => sub {
+ my $self = shift || confess("Call on an instance of MojoPlugins::Response");
+ my $code = shift || confess("Please supply a response code e.g. 400");
+ my $response_object = shift;
+
+ my $builder ||= MojoPlugins::Response::Builder->new($self, @_);
+ my @alerts_response = ({$LEVEL_KEY => $WARNING_LEVEL, $TEXT_KEY => "This endpoint and its functionality is deprecated, and will be removed in the future"});
+
+ if (defined($response_object)) {
+ return $self->render( $STATUS_KEY => $code, $JSON_KEY => { $ALERTS_KEY => \@alerts_response, $RESPONSE_KEY => $response_object } );
+ } else {
+ return $self->render( $STATUS_KEY => $code, $JSON_KEY => { $ALERTS_KEY => \@alerts_response } );
+ }
+ }
+ );
+
# Alerts (500)
$app->renderer->add_helper(
internal_server_error => sub {