You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
624 B
Go

package main
import (
"flag"
"log"
"net/http"
"os"
)
1 year ago
type application struct {
errorLog *log.Logger
infoLog *log.Logger
}
func main() {
addr := flag.String("addr", ":4000", "HTTP network address")
flag.Parse()
infoLog := log.New(os.Stdout, "INFO\t", log.Ldate|log.Ltime)
errorLog := log.New(os.Stderr, "ERROR\t", log.Ldate|log.Ltime|log.Lshortfile)
1 year ago
app := &application{
errorLog: errorLog,
infoLog: infoLog,
}
srv := &http.Server{
Addr: *addr,
ErrorLog: errorLog,
1 year ago
Handler: app.routes(),
}
infoLog.Printf("Starting server on %s", *addr)
err := srv.ListenAndServe()
errorLog.Fatal(err)
}