first commit
This commit is contained in:
68
main.go
Normal file
68
main.go
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
|
||||
* security | MatterLinux Package Security Tracker
|
||||
* MatterLinux 2023-2024 (https://matterlinux.xyz)
|
||||
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.matterlinux.xyz/matter/security/lib"
|
||||
"git.matterlinux.xyz/matter/security/routes"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/template/html/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFlags(log.Lshortfile | log.Ltime)
|
||||
|
||||
engine := html.New("./templates", ".html")
|
||||
app := fiber.New(fiber.Config{
|
||||
DisableStartupMessage: true,
|
||||
Views: engine,
|
||||
})
|
||||
|
||||
err := lib.LoadDatabase()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to load database: %s", err.Error())
|
||||
}
|
||||
|
||||
app.Static("/", "./public")
|
||||
app.Get("/", routes.GETIndex)
|
||||
app.Get("/details/:id", routes.GETDetails)
|
||||
|
||||
app.Get("/login", routes.GETLogin)
|
||||
app.Post("/login", routes.POSTLogin)
|
||||
|
||||
app.Use("/manage", routes.MiddleAuth)
|
||||
app.Get("/manage", routes.GETManage)
|
||||
app.Get("/manage/logout", routes.GETLogout)
|
||||
app.Post("/manage/new", routes.POSTNew)
|
||||
app.Post("/manage/status", routes.POSTStatus)
|
||||
|
||||
app.Get("*", func(c *fiber.Ctx) error {
|
||||
return lib.RenderError(c, 404)
|
||||
})
|
||||
|
||||
log.Printf("Starting MatterLinux Security Tracker on port 9876")
|
||||
err = app.Listen(":9876")
|
||||
if err != nil {
|
||||
log.Fatalf("Error starting server: %s", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user