-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
executable file
·34 lines (29 loc) · 1009 Bytes
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/auth", func(w http.ResponseWriter, r *http.Request) {
// Use client auth service to validate user credentials
// This is a placeholder for the actual authentication logic
// which would involve calling the internal/client/auth service and handling the response
username := r.URL.Query().Get("username")
password := r.URL.Query().Get("password")
if username == "admin" && password == "password" {
// Redirect to main page on successful login
w.Header().Set("Location", "/main")
w.WriteHeader(http.StatusFound)
} else {
// Inform the user of incorrect login details
w.WriteHeader(http.StatusUnauthorized)
fmt.Fprint(w, "Incorrect username or password")
}
})
// Serve static pages using the templ library
// This is a placeholder for static files serving
mux.Handle("/", http.FileServer(http.Dir("./static")))
log.Fatal(http.ListenAndServe(":8080", mux))
}