mhoppa commented on a change in pull request #3989: Rewrote
/deliveryservices/request to Go
URL: https://github.com/apache/trafficcontrol/pull/3989#discussion_r335655299
##########
File path: lib/go-tc/deliveryservice_requests.go
##########
@@ -20,15 +20,264 @@ import (
"encoding/json"
"errors"
"fmt"
+ "html/template"
"strconv"
"strings"
log "github.com/apache/trafficcontrol/lib/go-log"
)
+// EmailTemplate is an html/template.Template for formatting
DeliveryServiceRequestRequests into
+// text/html email bodies. Its direct use is discouraged, instead use
+// DeliveryServiceRequestRequest.Format.
+var EmailTemplate = template.Must(template.New("Email
Template").Parse(`<!DOCTYPE html>
+<html lang="en-US">
+<head>
+<meta charset="utf-8"/>
+<title>Delivery Service Request for {{.Customer}}</title>
+<style>
+aside {
+ padding: 0 1em;
+ color: #6A737D;
+ border-left: .25em solid #DFE2E5;
+}
+body {
+ font-family: sans;
+ background-color: white;
+}
+pre {
+ padding: 5px;
+ background-color: lightgray;
+}
+</style>
+</head>
+<body>
+<h1>Delivery Service Request for {{.Customer}}</h1>
+<p>{{.ServiceDesc}}</p>
+<section>
+ <details>
+ <summary><h2>Service Description</h2></summary>
+ <h3>Content Type</h3>
+ <p>{{.ContentType}}</p>
+ <h3>Delivery Protocol</h3>
+ <p>{{.DeliveryProtocol.String}}</p>
+ <h3>Routing Type</h3>
+ <p>{{.RoutingType.String}}</p>
+ </details>
+</section>
+<section>
+ <details>
+ <summary><h2>Traffic & Library Estimates</h2></summary>
+ <h3>Peak Bandwidth Estimate</h3>
+ <p>{{.PeakBPSEstimate}}Bps</p>
+ <h3>Peak Transactions per Second Estimate</h3>
+ <p>{{.PeakTPSEstimate}}Tps</p>
+ <h3>Max Library Size Estimate</h3>
+ <p>{{.MaxLibrarySizeEstimate}}GB</p>
+ </details>
+</section>
+<section>
+ <details>
+ <summary><h2>Origin Security</h2></summary>
+ <h3>Origin Server URL</h3>
+ <p><a href="{{.OriginURL}}">{{.OriginURL}}</a></p>
+ <h3>Origin Dynamic Remap</h3>
+ <p>{{.HasOriginDynamicRemap}}</p>
+ <h3>Origin Test File</h3>
+ <p>{{.OriginTestFile}}</p>
+ <h3>ACL/Whitelist to Access Origin</h3>
+ <p>{{.HasOriginACLWhitelist}}</p>
+ {{if .OriginHeaders}}<h3>Header(s) to Access Origin</h3>
Review comment:
should you check len of OriginHeaders as well. When giving it empty string
it renders to
<img width="304" alt="Screen Shot 2019-10-16 at 1 00 55 PM"
src="https://user-images.githubusercontent.com/54542891/66950112-03307e80-f015-11e9-86d8-cea6cf3e4122.png">
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services