Add main app
This commit is contained in:
parent
3bac1ddadc
commit
752d190fbc
|
|
@ -2,7 +2,7 @@ package config
|
||||||
|
|
||||||
import "github.com/jinzhu/configor"
|
import "github.com/jinzhu/configor"
|
||||||
|
|
||||||
// Configuration the application config can be set per env variables or config file (config.yml).
|
// Configuration is stuff that can be configured externally per env variables or config file (config.yml).
|
||||||
type Configuration struct {
|
type Configuration struct {
|
||||||
Port int `default:"8080"`
|
Port int `default:"8080"`
|
||||||
Database struct {
|
Database struct {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math/rand"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/jmattheis/memo/config"
|
||||||
|
"github.com/jmattheis/memo/database"
|
||||||
|
"github.com/jmattheis/memo/router"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
rand.Seed(time.Now().UnixNano())
|
||||||
|
conf := config.Get()
|
||||||
|
db, err := database.New(conf.Database.Dialect, conf.Database.Connection, conf.DefaultUser.Name, conf.DefaultUser.Pass)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
gin.SetMode(gin.ReleaseMode)
|
||||||
|
engine, closeable := router.Create(db)
|
||||||
|
defer closeable()
|
||||||
|
engine.Run(fmt.Sprintf(":%d", conf.Port))
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue