-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (31 loc) · 883 Bytes
/
main.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
35
36
37
38
// LibreDrive - A privacy oriented version of Google Drive
package main
import (
"embed"
"io/fs"
"log"
"net/http"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"libredrive/controllers"
"libredrive/global"
"libredrive/routers"
)
//go:embed public/*
var content embed.FS
func main() {
r := chi.NewRouter()
public, _ := fs.Sub(content, "public")
fs := http.FileServer(http.FS(public))
r.Use(middleware.Logger)
r.Handle("/*", fs)
r.Route("/nav", routers.NavRoute)
r.Route("/api/files", routers.FileRoutes)
r.Route("/api/users", routers.UserRoutes)
r.Post("/api/login", controllers.LoginUser)
r.Post("/api/register", controllers.CreateUser)
r.Get("/api/logout", controllers.LogoutUser)
r.Get("/api/activate/{id}", controllers.MarkUserActive)
log.Println("Server running on " + global.HOST)
log.Fatal(http.ListenAndServe(global.HOST, r))
}