24 lines
457 B
Go
24 lines
457 B
Go
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")
|
|
}
|
|
}
|