|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + auth "github.com/softwareplace/http-utils/oauth" |
| 5 | + "github.com/softwareplace/http-utils/security" |
4 | 6 | "github.com/softwareplace/http-utils/server" |
5 | 7 | "github.com/softwareplace/wireguard-api/pkg/domain/db" |
| 8 | + "github.com/softwareplace/wireguard-api/pkg/domain/service/api_secret_service" |
6 | 9 | "github.com/softwareplace/wireguard-api/pkg/domain/service/peer" |
7 | 10 | "github.com/softwareplace/wireguard-api/pkg/domain/service/user_service" |
8 | 11 | "github.com/softwareplace/wireguard-api/pkg/handlers" |
9 | 12 | "github.com/softwareplace/wireguard-api/pkg/handlers/request" |
10 | 13 | "github.com/softwareplace/wireguard-api/pkg/handlers/user/user_handler" |
| 14 | + "github.com/softwareplace/wireguard-api/pkg/utils/env" |
11 | 15 | ) |
12 | 16 |
|
13 | 17 | func main() { |
| 18 | + appEnv := env.AppEnv() |
14 | 19 | db.InitMongoDB() |
15 | | - api := server.New[*request.ApiContext]() |
16 | | - api.Use(request.ContextBuilder, "API/CONTEXT/INITIALIZER") |
17 | | - |
18 | 20 | service := user_service.GetService() |
19 | 21 | userAuthenticationUserHandler := user_handler.GetAuthenticationUserHandler(&service) |
20 | | - api.Use(userAuthenticationUserHandler.Handler, "MIDDLEWARE/AUTHENTICATION_USER") |
| 22 | + api := server.New[*request.ApiContext]( |
| 23 | + request.ContextBuilder, |
| 24 | + userAuthenticationUserHandler.Handler, |
| 25 | + ) |
21 | 26 |
|
22 | | - handlers.Init(&api) |
| 27 | + secretService := api_secret_service.GetService() |
| 28 | + securityService := security.GetApiSecurityService[*request.ApiContext](appEnv.ApiSecretAuthorization) |
| 29 | + auth.Handler(appEnv.ApiSecretKey, secretService.GetKey, &securityService, api) |
| 30 | + handlers.Init(api) |
23 | 31 | peer.GetService().Load() |
24 | 32 | service.Init() |
25 | 33 | api.StartServer() |
|
0 commit comments