-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.go
42 lines (35 loc) · 1.18 KB
/
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
package main
import (
"github.com/create-go-app/net_http-go-template/pkg/configs"
"github.com/create-go-app/net_http-go-template/pkg/routes"
"github.com/create-go-app/net_http-go-template/pkg/utils"
"github.com/gorilla/mux"
_ "github.com/create-go-app/net_http-go-template/docs" // load Swagger docs
_ "github.com/joho/godotenv/autoload" // load .env file automatically
)
// @title API
// @version 1.0
// @description This is an auto-generated API Docs for Golang net/http Template.
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.email [email protected]
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
// @BasePath /api
func main() {
// Initialize a new router.
router := mux.NewRouter()
// List of app routes:
routes.PublicRoutes(router)
routes.PrivateRoutes(router)
routes.SwaggerRoutes(router)
// Register middleware.
router.Use(mux.CORSMethodMiddleware(router)) // enable CORS
// Initialize server.
server := configs.ServerConfig(router)
// Start API server.
utils.StartServerWithGracefulShutdown(server)
}