init
This commit is contained in:
commit
2586161abd
49 changed files with 4171 additions and 0 deletions
24
web/run.go
Normal file
24
web/run.go
Normal 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")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue