adds
This commit is contained in:
parent
c51da2a965
commit
656333275b
4
.gitignore
vendored
4
.gitignore
vendored
@ -20,6 +20,10 @@ go.work
|
||||
# Project specific binaries
|
||||
erp_system
|
||||
|
||||
erp.db
|
||||
erp.db-shm
|
||||
erp.db-wal
|
||||
erp_system
|
||||
# SQLite
|
||||
*.db
|
||||
*.db-shm
|
||||
|
||||
BIN
erp.db-shm
BIN
erp.db-shm
Binary file not shown.
BIN
erp_system
BIN
erp_system
Binary file not shown.
4
main.go
4
main.go
@ -45,6 +45,10 @@ func main() {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Static/public routes
|
||||
mux.Handle("/resources/", http.StripPrefix("/resources/", http.FileServer(http.Dir("resources"))))
|
||||
mux.HandleFunc("GET /favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "resources/favicon.png")
|
||||
})
|
||||
mux.HandleFunc("GET /login", h.LoginPage)
|
||||
mux.HandleFunc("POST /login", h.LoginSubmit)
|
||||
mux.HandleFunc("POST /logout", h.Logout)
|
||||
|
||||
42
main_test.go
Normal file
42
main_test.go
Normal file
@ -0,0 +1,42 @@
|
||||
package main_test
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestResources_Favicon(t *testing.T) {
|
||||
// Create resources directory and dummy favicon if not exists
|
||||
if _, err := os.Stat("resources"); os.IsNotExist(err) {
|
||||
os.Mkdir("resources", 0755)
|
||||
}
|
||||
if _, err := os.Stat("resources/favicon.png"); os.IsNotExist(err) {
|
||||
os.WriteFile("resources/favicon.png", []byte("dummy"), 0644)
|
||||
defer os.Remove("resources/favicon.png")
|
||||
}
|
||||
|
||||
// Setup handler exactly as in main.go
|
||||
mux := http.NewServeMux()
|
||||
mux.Handle("/resources/", http.StripPrefix("/resources/", http.FileServer(http.Dir("resources"))))
|
||||
mux.HandleFunc("GET /favicon.ico", func(w http.ResponseWriter, r *http.Request) {
|
||||
http.ServeFile(w, r, "resources/favicon.png")
|
||||
})
|
||||
|
||||
// Test request for resources path
|
||||
req := httptest.NewRequest("GET", "/resources/favicon.png", nil)
|
||||
w := httptest.NewRecorder()
|
||||
mux.ServeHTTP(w, req)
|
||||
if w.Code != http.StatusOK {
|
||||
t.Errorf("GET /resources/favicon.png failed: %d", w.Code)
|
||||
}
|
||||
|
||||
// Test request for favicon.ico
|
||||
reqIco := httptest.NewRequest("GET", "/favicon.ico", nil)
|
||||
wIco := httptest.NewRecorder()
|
||||
mux.ServeHTTP(wIco, reqIco)
|
||||
if wIco.Code != http.StatusOK {
|
||||
t.Errorf("GET /favicon.ico failed: %d", wIco.Code)
|
||||
}
|
||||
}
|
||||
BIN
resources/favicon.png
Normal file
BIN
resources/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
@ -4,6 +4,8 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/png" sizes="64x64" href="/resources/favicon.png?v=1">
|
||||
|
||||
<title>{{.Title}} - ERP System</title>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="icon" type="image/png" href="/resources/favicon.png">
|
||||
<title>Login - ERP System</title>
|
||||
<script src="https://unpkg.com/htmx.org@2.0.4"></script>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user