platform: modularize api/gui, add docs-tests-web foundation, and refresh root config
This commit is contained in:
38
selective-vpn-api/app/api_bootstrap.go
Normal file
38
selective-vpn-api/app/api_bootstrap.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"net/http"
|
||||
appbootstrap "selective-vpn-api/app/bootstrap"
|
||||
"time"
|
||||
)
|
||||
|
||||
func runAPIServerAtAddr(addr string) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
prepareAPIRuntime()
|
||||
|
||||
log.Printf("selective-vpn API listening on %s", addr)
|
||||
if err := appbootstrap.Run(ctx, appbootstrap.Config{
|
||||
Addr: addr,
|
||||
ReadHeaderTimeout: 5 * time.Second,
|
||||
RegisterRoutes: registerAPIRoutes,
|
||||
WrapHandler: logRequests,
|
||||
StartWatchers: startWatchers,
|
||||
}); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("server error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func prepareAPIRuntime() {
|
||||
ensureSeeds()
|
||||
if err := ensureAppMarksNft(); err != nil {
|
||||
log.Printf("traffic appmarks nft init warning: %v", err)
|
||||
}
|
||||
if err := restoreAppMarksFromState(); err != nil {
|
||||
log.Printf("traffic appmarks restore warning: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user