-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.go
More file actions
54 lines (48 loc) · 1.61 KB
/
server.go
File metadata and controls
54 lines (48 loc) · 1.61 KB
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
47
48
49
50
51
52
53
54
package main
import (
"os"
"path/filepath"
"runtime"
"devtoolbox/pkg/router"
"devtoolbox/service"
)
func themesDir() string {
if runtime.GOOS == "darwin" {
return filepath.Join(os.Getenv("HOME"), "Library", "Application Support", "DevToolbox", "themes")
} else if runtime.GOOS == "windows" {
return filepath.Join(os.Getenv("APPDATA"), "DevToolbox", "themes")
}
return filepath.Join(os.Getenv("HOME"), ".config", "devtoolbox", "themes")
}
// StartHTTPServer starts the HTTP server with all services registered
func StartHTTPServer(port int) {
// Create services
jwtSvc := service.NewJWTService(nil)
encrypterSvc := service.NewEncrypterService(nil)
encoderSvc := service.NewEncoderService(nil)
hashGenSvc := service.NewHashGeneratorService(nil)
codeConvSvc := service.NewCodeConverterService(nil)
textUtilsSvc := service.NewTextUtilitiesService(nil)
barcodeSvc := service.NewBarcodeService(nil)
dataGenSvc := service.NewDataGeneratorService(nil)
codeFmtSvc := service.NewCodeFormatterService(nil)
dateTimeSvc := service.NewDateTimeService(nil)
numberConvSvc := service.NewNumberConverterService(nil)
themesSvc := service.NewThemesService(nil, themesDir())
// Create server and register services
server := router.NewServer()
server.Register(jwtSvc)
server.Register(encrypterSvc)
server.Register(encoderSvc)
server.Register(hashGenSvc)
server.Register(codeConvSvc)
server.Register(textUtilsSvc)
server.Register(barcodeSvc)
server.Register(dataGenSvc)
server.Register(codeFmtSvc)
server.Register(dateTimeSvc)
server.Register(numberConvSvc)
server.Register(themesSvc)
// Start server
server.Start(port)
}