Skip to content

Commit

Permalink
Serve from /docs
Browse files Browse the repository at this point in the history
  • Loading branch information
theleeeo committed Jan 30, 2024
1 parent d90f509 commit c38787f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ func getCompanyLogo(location string) ([]byte, error) {
}

func registerHandlers(a *App) {
a.fiberApp.Get("/favicon.ico", func(c *fiber.Ctx) error {
a.fiberApp.Get("/docs/favicon.ico", func(c *fiber.Ctx) error {
return c.Send(a.logo)
})

// Serve static files
a.fiberApp.Static("/", staticFilesPath)
a.fiberApp.Static("/docs/", staticFilesPath)

a.fiberApp.Get("/", a.getIndexHandler)
a.fiberApp.Get("/:version/:role", a.renderDocHandler)
a.fiberApp.Get("/docs/", a.getIndexHandler)
a.fiberApp.Get("/docs/:version/:role", a.renderDocHandler)

a.fiberApp.Get("/versions", a.getVersionsHandler)
a.fiberApp.Get("/version/:version/roles", a.getRolesHandler)
a.fiberApp.Get("/docs/versions", a.getVersionsHandler)
a.fiberApp.Get("/docs/version/:version/roles", a.getRolesHandler)
}

func validateConfig(cfg *Config) error {
Expand Down
6 changes: 3 additions & 3 deletions public/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ window.onload = function () {
};

function setupVersionSelect() {
fetch('/versions')
fetch('/docs/versions')
.then(response => response.json())
.then(versions => {
var dropdown = document.getElementById('dropdown');
Expand All @@ -22,7 +22,7 @@ function setupVersionSelect() {

function handleVersionSelect() {
const version = document.getElementById('dropdown').value;
fetch(`/version/${version}/roles`)
fetch(`/docs/version/${version}/roles`)
.then(response => response.json())
.then(roles => {
buttonContainer = document.getElementById('button-container');
Expand All @@ -32,7 +32,7 @@ function handleVersionSelect() {
button.innerHTML = role;

button.onclick = function () {
window.location.href = `/${version}/${role}`;
window.location.href = `/docs/${version}/${role}`;
};

buttonContainer.appendChild(button);
Expand Down
2 changes: 1 addition & 1 deletion views/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>{{ .CompanyName }} Api</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/docs/style.css">
</head>

<body>
Expand Down
4 changes: 2 additions & 2 deletions views/partials/header.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<header>
<a href="/">
<a href="/docs/">
<img src="{{ .CompanyLogo }}" alt="company logo">
</a>
<a href="/">
<a href="/docs/">
<h1>{{ .CompanyName }}</h1>
</a>
</header>
2 changes: 1 addition & 1 deletion views/version-select.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ <h2>Select documentation:</h2>
</div>
</div>
</div>
<script src="/script.js"></script>
<script src="/docs/script.js"></script>

0 comments on commit c38787f

Please sign in to comment.