-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
37 lines (30 loc) · 960 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
package main
import (
"io"
"log"
"net/http"
"strings"
"github.com/flume-cloud-services/file-storage/controllers"
"github.com/flume-cloud-services/file-storage/middleware"
)
func main() {
http.HandleFunc("/signin", controllers.Signin)
http.Handle("/welcome", middleware.Middleware(
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Welcome to you visitor !")
}),
middleware.AuthMiddleware,
))
http.Handle("/post", middleware.Middleware(
http.HandlerFunc(controllers.PostFile),
middleware.AuthMiddleware,
))
http.Handle("/private/", middleware.Middleware(
http.StripPrefix(strings.TrimRight("/private/", "/"),
http.FileServer(http.Dir("private"))),
middleware.AuthMiddleware,
))
http.Handle("/public/", http.StripPrefix(strings.TrimRight("/public/", "/"), http.FileServer(http.Dir("public"))))
log.Println("Starting server on port :8080")
log.Fatal(http.ListenAndServe(":8080", nil))
}