Skip to content

Commit

Permalink
#1 Read templateUrl out of etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
sklein94 committed May 26, 2020
1 parent 58149b6 commit 1130e2d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions resources/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ set -o pipefail

NGINX_ROOT=/var/www/html
INDEX_FILE=$NGINX_ROOT/index.html
INDEX_TEMPLATE_PATH=/var/www/html/index.html.tpl
INDEX_FILE_PATH=/var/www/html/index.html
doguctl state "starting"

# remove swagger.json from index.html
sed -i "s|https://petstore.swagger.io/v2/swagger.json||g" $INDEX_FILE

doguctl template "${INDEX_TEMPLATE_PATH}" "${INDEX_FILE_PATH}"

doguctl state "ready"

# Start nginx
Expand Down
65 changes: 65 additions & 0 deletions resources/var/www/html/index.html.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style>
html
{
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after
{
box-sizing: inherit;
}
body
{
margin:0;
background: #fafafa;
}
</style>
</head>

<body>
<div id="swagger-ui"></div>

<script src="./swagger-ui-bundle.js"> </script>
<script src="./swagger-ui-standalone-preset.js"> </script>
<script>
window.onload = function() {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({
url: "",
dom_id: '#swagger-ui',
deepLinking: true,
{{ if .Config.Exists "validator.url" }}
validatorUrl: "{{ .Config.Get "validator.url"}}",
{{ else }}
validatorUrl: null,
{{ end }}
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
})
// End Swagger UI call region
window.ui = ui
}
</script>
</body>
</html>

0 comments on commit 1130e2d

Please sign in to comment.