You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.8 KiB
45 lines
1.8 KiB
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"marmic/servicetrade-toolbox/internal/handlers"
|
|
"marmic/servicetrade-toolbox/internal/middleware"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
func main() {
|
|
r := mux.NewRouter()
|
|
|
|
// Serve static files
|
|
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
|
|
|
// Auth routes
|
|
r.HandleFunc("/login", handlers.LoginHandler).Methods("GET", "POST")
|
|
r.HandleFunc("/logout", handlers.LogoutHandler).Methods("GET", "POST")
|
|
|
|
// Protected routes
|
|
protected := r.PathPrefix("/").Subrouter()
|
|
protected.Use(middleware.AuthMiddleware)
|
|
|
|
protected.HandleFunc("/", handlers.DashboardHandler).Methods("GET")
|
|
protected.HandleFunc("/jobs", handlers.JobsHandler).Methods("GET")
|
|
protected.HandleFunc("/admin", handlers.AdminHandler).Methods("GET")
|
|
protected.HandleFunc("/assets", handlers.AssetsHandler).Methods("GET")
|
|
protected.HandleFunc("/companies", handlers.CompaniesHandler).Methods("GET")
|
|
protected.HandleFunc("/contacts", handlers.ContactsHandler).Methods("GET")
|
|
protected.HandleFunc("/contracts", handlers.ContractsHandler).Methods("GET")
|
|
protected.HandleFunc("/generic", handlers.GenericHandler).Methods("GET")
|
|
protected.HandleFunc("/invoices", handlers.InvoicesHandler).Methods("GET", "POST")
|
|
protected.HandleFunc("/locations", handlers.LocationsHandler).Methods("GET")
|
|
protected.HandleFunc("/notifications", handlers.NotificationsHandler).Methods("GET")
|
|
protected.HandleFunc("/quotes", handlers.QuotesHandler).Methods("GET")
|
|
protected.HandleFunc("/services", handlers.ServicesHandler).Methods("GET")
|
|
protected.HandleFunc("/tags", handlers.TagsHandler).Methods("GET")
|
|
protected.HandleFunc("/users", handlers.UsersHandler).Methods("GET")
|
|
|
|
log.Println("Server starting on :8080")
|
|
log.Fatal(http.ListenAndServe(":8080", r))
|
|
}
|
|
|