mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-09 01:12:52 +00:00
39 lines
836 B
Go
39 lines
836 B
Go
package main
|
|
|
|
import (
|
|
"github.com/NYTimes/gziphandler"
|
|
"log"
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"./controller/api"
|
|
"./db"
|
|
"./route"
|
|
"./utils"
|
|
)
|
|
|
|
func main() {
|
|
configurations := utils.ReadConfig()
|
|
|
|
db.Configure(configurations.Database)
|
|
api.Configure(configurations.Api)
|
|
|
|
db.Mongo.Connect()
|
|
|
|
//register middleware
|
|
handle := gziphandler.GzipHandler(route.Routes())
|
|
|
|
log.Println("Starting Server...")
|
|
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
|
|
|
|
/* enable for TLS support
|
|
go func(){
|
|
log.Println(http.ListenAndServe(":"+strconv.Itoa(configurations.Port), handle))
|
|
}()
|
|
|
|
if configurations.TLSCertFile != "" && configurations.TLSKeyFile != "" {
|
|
log.Println(http.ListenAndServeTLS(":"+strconv.Itoa(configurations.TLSPort), configurations.TLSCertFile, configurations.TLSKeyFile, handle))
|
|
}
|
|
*/
|
|
}
|