Skip to content

Commit

Permalink
Some refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbalex committed Oct 10, 2019
1 parent 1429505 commit f61f3cf
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,25 @@ type App struct {
// main server start
func main() {
app := App{}
app.init()
app.Run()
}

func (app *App) init() {
app.Port = "5000"
app.DisableNetwork = false
app.Router = mux.NewRouter()
app.initializeRouters()
}

// Run http server
func (app *App) Run() {
log.Printf("server is starting at port %s", app.Port)
log.Fatal(http.ListenAndServe(":"+app.Port, app.Router))
}

func (app *App) initializeRouters() {
//init router
app.Router = mux.NewRouter()

app.Router.
HandleFunc("/pc/validate", app.validateParam).
Methods("POST", "OPTIONS").
Expand All @@ -53,10 +63,6 @@ func (app *App) initializeRouters() {
app.Router.
HandleFunc("/pc/validate", app.validate).
Methods("POST", "OPTIONS")

log.Printf("server is starting at port %s", app.Port)
log.Fatal(http.ListenAndServe(":"+app.Port, app.Router))

}

// setupResponse set CORS header
Expand Down

0 comments on commit f61f3cf

Please sign in to comment.