-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (34 loc) · 796 Bytes
/
main.go
File metadata and controls
46 lines (34 loc) · 796 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
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"fmt"
"log/slog"
"net/http"
"os"
"time"
"github.com/fatih/color"
"github.com/gin-gonic/gin"
"github.com/tinkerbaj/redditjobs/router"
"github.com/tinkerbaj/redditjobs/utils"
)
//Just simple main file
func main() {
// Start the server
if err := runServer(); err != nil {
slog.Error("Failed to start server!", "details", err.Error())
os.Exit(1)
}
}
func runServer() error {
app := gin.Default()
app.HTMLRender = &utils.TemplRender{}
router.SetRouter(app)
server := &http.Server{
Addr: fmt.Sprintf("localhost:%d", 7070),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
Handler: app,
}
d := color.New(color.FgBlue, color.Bold)
d.Printf("Starting server on port %d\n", 7070)
return server.ListenAndServe()
}