Implement favicon and static file support

This commit is contained in:
Jan Dittberner 2021-01-01 15:43:24 +01:00
parent c3117c8abe
commit 3f43a07f9f
18 changed files with 52 additions and 3 deletions

View file

@ -131,13 +131,18 @@ func main() {
if err != nil { if err != nil {
logger.Fatalf("could not initialize index handler: %v", err) logger.Fatalf("could not initialize index handler: %v", err)
} }
callbackHandler := handlers.NewCallbackHandler(ctx) callbackHandler := handlers.NewCallbackHandler(ctx, logger)
afterLogoutHandler := handlers.NewAfterLogoutHandler(logger) afterLogoutHandler := handlers.NewAfterLogoutHandler(logger)
staticFiles := http.FileServer(http.Dir("static"))
router := http.NewServeMux() router := http.NewServeMux()
router.Handle("/", authMiddleware(indexHandler)) router.Handle("/", authMiddleware(indexHandler))
router.Handle("/callback", callbackHandler) router.Handle("/callback", callbackHandler)
router.Handle("/after-logout", afterLogoutHandler) router.Handle("/after-logout", afterLogoutHandler)
router.Handle("/health", commonHandlers.NewHealthHandler())
router.Handle("/images/", staticFiles)
router.Handle("/css/", staticFiles)
router.Handle("/js/", staticFiles)
nextRequestId := func() string { nextRequestId := func() string {
return fmt.Sprintf("%d", time.Now().UnixNano()) return fmt.Sprintf("%d", time.Now().UnixNano())

View file

@ -105,6 +105,7 @@ func main() {
logoutHandler := handlers.NewLogoutHandler(handlerContext, logger) logoutHandler := handlers.NewLogoutHandler(handlerContext, logger)
logoutSuccessHandler := handlers.NewLogoutSuccessHandler() logoutSuccessHandler := handlers.NewLogoutSuccessHandler()
errorHandler := handlers.NewErrorHandler() errorHandler := handlers.NewErrorHandler()
staticFiles := http.FileServer(http.Dir("static"))
router := http.NewServeMux() router := http.NewServeMux()
router.Handle("/login", loginHandler) router.Handle("/login", loginHandler)
@ -113,6 +114,9 @@ func main() {
router.Handle("/error", errorHandler) router.Handle("/error", errorHandler)
router.Handle("/logout-successful", logoutSuccessHandler) router.Handle("/logout-successful", logoutSuccessHandler)
router.Handle("/health", commonHandlers.NewHealthHandler()) router.Handle("/health", commonHandlers.NewHealthHandler())
router.Handle("/images/", staticFiles)
router.Handle("/css/", staticFiles)
router.Handle("/js/", staticFiles)
if err != nil { if err != nil {
logger.Fatal(err) logger.Fatal(err)

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 7.4 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -1,7 +1,25 @@
{{ define "base" }} {{ define "base" }}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head><title>{{ .Title }}</title></head> <head>
<title>{{ .Title }}</title>
<!-- generics -->
<link rel="icon" href="/images/favicon-32.png" sizes="32x32">
<link rel="icon" href="/images/favicon-57.png" sizes="57x57">
<link rel="icon" href="/images/favicon-76.png" sizes="76x76">
<link rel="icon" href="/images/favicon-96.png" sizes="96x96">
<link rel="icon" href="/images/favicon-128.png" sizes="128x128">
<link rel="icon" href="/images/favicon-192.png" sizes="192x192">
<link rel="icon" href="/images/favicon-228.png" sizes="228x228">
<!-- Android -->
<link rel="shortcut icon" sizes="196x196" href="/images/favicon-196.png">
<!-- iOS -->
<link rel="apple-touch-icon" href="/images/favicon-120.png" sizes="120x120">
<link rel="apple-touch-icon" href="/images/favicon-152.png" sizes="152x152">
<link rel="apple-touch-icon" href="/images/favicon-180.png" sizes="180x180">
</head>
<body> <body>
{{ template "content" . }} {{ template "content" . }}
</body> </body>

View file

@ -1,7 +1,25 @@
{{ define "base" }} {{ define "base" }}
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head><title>{{ .Title }}</title></head> <head>
<title>{{ .Title }}</title>
<!-- generics -->
<link rel="icon" href="/images/favicon-32.png" sizes="32x32">
<link rel="icon" href="/images/favicon-57.png" sizes="57x57">
<link rel="icon" href="/images/favicon-76.png" sizes="76x76">
<link rel="icon" href="/images/favicon-96.png" sizes="96x96">
<link rel="icon" href="/images/favicon-128.png" sizes="128x128">
<link rel="icon" href="/images/favicon-192.png" sizes="192x192">
<link rel="icon" href="/images/favicon-228.png" sizes="228x228">
<!-- Android -->
<link rel="shortcut icon" sizes="196x196" href="/images/favicon-196.png">
<!-- iOS -->
<link rel="apple-touch-icon" href="/images/favicon-120.png" sizes="120x120">
<link rel="apple-touch-icon" href="/images/favicon-152.png" sizes="152x152">
<link rel="apple-touch-icon" href="/images/favicon-180.png" sizes="180x180">
</head>
<body> <body>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
{{ template "content" . }} {{ template "content" . }}