37 lines
501 B
Go
37 lines
501 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"authentication/data"
|
||
|
"database/sql"
|
||
|
"fmt"
|
||
|
"log"
|
||
|
"net/http"
|
||
|
)
|
||
|
|
||
|
const webPort = "4000"
|
||
|
|
||
|
type Config struct {
|
||
|
DB *sql.DB
|
||
|
Models data.Models
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
// TODO connect to DB
|
||
|
|
||
|
// set up config
|
||
|
app := Config{}
|
||
|
|
||
|
log.Printf("Starting authentication service on port %s\n", webPort)
|
||
|
|
||
|
// define http server
|
||
|
srv := &http.Server{
|
||
|
Addr: fmt.Sprintf(":%s", webPort),
|
||
|
Handler: app.routes(),
|
||
|
}
|
||
|
|
||
|
err := srv.ListenAndServe()
|
||
|
if err != nil {
|
||
|
log.Panic(err)
|
||
|
}
|
||
|
}
|