github.com/EngineerKamesh/gofullstack@v0.0.0-20180609171605-d41341d7d4ee/volume2/section4/gopherfaceform/gopherface.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/EngineerKamesh/gofullstack/volume2/section4/gopherfaceform/handlers"
     5  	"github.com/EngineerKamesh/gofullstack/volume2/section4/gopherfaceform/middleware"
     6  
     7  	"net/http"
     8  	"os"
     9  
    10  	ghandlers "github.com/gorilla/handlers"
    11  	"github.com/gorilla/mux"
    12  )
    13  
    14  const (
    15  	WEBSERVERPORT = ":8080"
    16  )
    17  
    18  func main() {
    19  
    20  	r := mux.NewRouter()
    21  	r.HandleFunc("/", handlers.HomeHandler)
    22  	r.HandleFunc("/register", handlers.RegisterHandler).Methods("GET,POST")
    23  	r.HandleFunc("/login", handlers.LoginHandler).Methods("POST")
    24  	r.HandleFunc("/logout", handlers.LogoutHandler).Methods("POST")
    25  	r.HandleFunc("/feed", handlers.FeedHandler).Methods("GET")
    26  	r.HandleFunc("/friends", handlers.FriendsHandler).Methods("GET")
    27  	r.HandleFunc("/find", handlers.FindHandler).Methods("GET,POST")
    28  	r.HandleFunc("/profile", handlers.MyProfileHandler).Methods("GET")
    29  	r.HandleFunc("/profile/{username}", handlers.ProfileHandler)
    30  	r.HandleFunc("/triggerpanic", handlers.TriggerPanicHandler)
    31  	r.HandleFunc("/foo", handlers.FooHandler)
    32  	r.HandleFunc("/signup", handlers.SignUpHandler).Methods("GET", "POST")
    33  	r.HandleFunc("/postpreview", handlers.PostPreviewHandler).Methods("GET", "POST")
    34  	r.HandleFunc("/upload-image", handlers.UploadImageHandler).Methods("GET", "POST")
    35  	r.HandleFunc("/upload-video", handlers.UploadVideoHandler).Methods("GET", "POST")
    36  	r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
    37  	http.Handle("/", middleware.PanicRecoveryHandler(ghandlers.LoggingHandler(os.Stdout, r)))
    38  	http.ListenAndServe(WEBSERVERPORT, nil)
    39  
    40  }