-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
35 lines (25 loc) · 782 Bytes
/
main.go
File metadata and controls
35 lines (25 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"log"
"net/http"
"time"
messaging_http "alexandre-gerault.fr/gochat-server/internal/messaging/ui/http"
shared_infrastructure "alexandre-gerault.fr/gochat-server/internal/shared/infrastructure"
)
func main() {
app := shared_infrastructure.Application{}
app.Register()
shared_infrastructure.RunMigrations()
log.Println("Start http server (http://localhost:8080)...")
router := http.NewServeMux()
router.HandleFunc("POST /messages/", messaging_http.NewSendMessageEndpoint(&app))
httpServer := &http.Server{
Addr: ":8080",
Handler: router,
ReadTimeout: 10 * time.Second,
WriteTimeout: 10 * time.Second,
MaxHeaderBytes: 1 << 20,
}
log.Fatal(httpServer.ListenAndServe())
log.Println("Gracefully shutdown.")
}