This commit is contained in:
sam 2023-09-03 00:23:48 +02:00
commit 2586161abd
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
49 changed files with 4171 additions and 0 deletions

24
web/run.go Normal file
View file

@ -0,0 +1,24 @@
package web
import (
"context"
"net/http"
"strconv"
"git.sleepycat.moe/sam/mercury/web/app"
"github.com/rs/zerolog/log"
)
func Run(ctx context.Context, app *app.App, port int) {
listenAddr := ":" + strconv.Itoa(port)
ech := make(chan error)
go func() {
ech <- http.ListenAndServe(listenAddr, app.Router)
}()
log.Info().Int("port", port).Msg("Running API server")
if err := <-ech; err != nil {
log.Err(err).Msg("Running API server")
}
}