-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8fa9117
commit 1ba2ab1
Showing
9 changed files
with
125 additions
and
2 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,27 @@ | ||
package handler | ||
|
||
import ( | ||
"github.com/labstack/echo/v4" | ||
"github.com/teamhanko/hanko/backend/persistence" | ||
"net/http" | ||
) | ||
|
||
type StatusHandler struct { | ||
persister persistence.Persister | ||
} | ||
|
||
func NewStatusHandler(persister persistence.Persister) *StatusHandler { | ||
return &StatusHandler{ | ||
persister: persister, | ||
} | ||
} | ||
|
||
func (h *StatusHandler) Status(c echo.Context) error { | ||
// random query to check DB connectivity | ||
_, err := h.persister.GetJwkPersister().GetAll() | ||
if err != nil { | ||
return c.Render(http.StatusInternalServerError, "status", map[string]bool{"dbError": true}) | ||
} | ||
|
||
return c.Render(http.StatusOK, "status", nil) | ||
} |
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,25 @@ | ||
package template | ||
|
||
import ( | ||
"embed" | ||
"github.com/labstack/echo/v4" | ||
"html/template" | ||
"io" | ||
) | ||
|
||
//go:embed templates/* | ||
var templateFS embed.FS | ||
|
||
type Template struct { | ||
templates *template.Template | ||
} | ||
|
||
func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Context) error { | ||
return t.templates.ExecuteTemplate(w, name, data) | ||
} | ||
|
||
func NewTemplateRenderer() *Template { | ||
return &Template{ | ||
templates: template.Must(template.ParseFS(templateFS, "templates/*.tmpl")), | ||
} | ||
} |
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,17 @@ | ||
{{define "status"}} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>API Integration Status</title> | ||
</head> | ||
<body> | ||
<h1>API Status</h1> | ||
{{if .dbError}} | ||
<p>❌ API is not functioning properly due to database connectivity problems.</p> | ||
{{else}} | ||
<p>✅ API is running.</p> | ||
<p>Check integration guides on <a href="https://docs.hanko.io" target="_blank">docs.hanko.io</a></p> | ||
{{end}} | ||
</body> | ||
</html> | ||
{{end}} |
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