-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
44 lines (36 loc) · 855 Bytes
/
main.go
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
package main
import (
"log"
"net/http"
"time"
"github.com/ganpatagarwal/chi-swagger/handlers"
_ "github.com/ganpatagarwal/chi-swagger/docs"
"github.com/ganpatagarwal/chi-swagger/router"
httpSwagger "github.com/swaggo/http-swagger"
)
// @title chi-swagger example APIs
// @version 1.0
// @description chi-swagger example APIs
// @BasePath /
func main() {
var timeout = 2 * time.Minute
var routes = []router.Route{
router.Route{
Method: "GET",
Path: "/",
HandlerFunc: handlers.RootHandler,
},
}
log.Println("Launching the server")
r := router.NewRouter(routes)
r.Mount("/swagger", httpSwagger.WrapHandler)
server := http.Server{
ReadTimeout: timeout,
WriteTimeout: timeout,
Handler: r,
}
err := server.ListenAndServe()
if err != nil {
log.Printf("Failed to launch api server:%+v\n", err)
}
}