Fix configurations
This commit is contained in:
43
.gitignore
vendored
43
.gitignore
vendored
@@ -3,30 +3,30 @@
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
# .idea/**/workspace.xml
|
||||
# .idea/**/tasks.xml
|
||||
# .idea/**/usage.statistics.xml
|
||||
# .idea/**/dictionaries
|
||||
# .idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
# .idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
# .idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
# .idea/**/dataSources/
|
||||
# .idea/**/dataSources.ids
|
||||
# .idea/**/dataSources.local.xml
|
||||
# .idea/**/sqlDataSources.xml
|
||||
# .idea/**/dynamic.xml
|
||||
# .idea/**/uiDesigner.xml
|
||||
# .idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
# .idea/**/gradle.xml
|
||||
# .idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
@@ -38,6 +38,7 @@
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
.idea
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
@@ -45,7 +46,7 @@
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
#.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
@@ -60,10 +61,10 @@ out/
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
#.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
#.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
@@ -72,10 +73,10 @@ crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
#.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
# .idea/caches/build_file_checksums.ser
|
||||
|
||||
### Linux template
|
||||
*~
|
||||
|
||||
10
.idea/.gitignore
generated
vendored
10
.idea/.gitignore
generated
vendored
@@ -1,10 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Environment-dependent path to Maven home directory
|
||||
/mavenHomeManager.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
7
.idea/codeStyles/Project.xml
generated
7
.idea/codeStyles/Project.xml
generated
@@ -1,7 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<ScalaCodeStyleSettings>
|
||||
<option name="MULTILINE_STRING_CLOSING_QUOTES_ON_NEW_LINE" value="true" />
|
||||
</ScalaCodeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
||||
5
.idea/codeStyles/codeStyleConfig.xml
generated
5
.idea/codeStyles/codeStyleConfig.xml
generated
@@ -1,5 +0,0 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
15
.idea/git_toolbox_prj.xml
generated
15
.idea/git_toolbox_prj.xml
generated
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GitToolBoxProjectSettings">
|
||||
<option name="commitMessageIssueKeyValidationOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
<option name="commitMessageValidationEnabledOverride">
|
||||
<BoolValueOverride>
|
||||
<option name="enabled" value="true" />
|
||||
</BoolValueOverride>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/misc.xml
generated
6
.idea/misc.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/fileserver.iml" filepath="$PROJECT_DIR$/fileserver.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -22,14 +22,14 @@ func main() {
|
||||
log.Fatalf("Error to read %s configuration: %v\n", profile, err)
|
||||
}
|
||||
log.Printf("Application starting with profile: %s", profile)
|
||||
server := config.App.Server
|
||||
mux := http.NewServeMux()
|
||||
// Register all routes in the new ServeMux
|
||||
mux := http.NewServeMux()
|
||||
log.Printf("Register all routes\n")
|
||||
for url, handler := range api.Routes {
|
||||
log.Printf("Register route %s for %v", url, getFunctionName(handler))
|
||||
mux.HandleFunc(url, handler)
|
||||
}
|
||||
server := config.App.Server
|
||||
url := fmt.Sprintf("%s:%d", server.Host, server.Port)
|
||||
log.Printf("Start server on %s\n", url)
|
||||
if err := http.ListenAndServe(url, mux); err != nil {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"server": {
|
||||
"host": "localhost",
|
||||
"port": 8080
|
||||
"port": 8081
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"server": {
|
||||
"host": "localhost",
|
||||
"port": 8089
|
||||
"port": 8080
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -21,19 +20,21 @@ var App Application
|
||||
const configDir = "config"
|
||||
|
||||
func Initialize(profile string) error {
|
||||
filename := checkProfileAndGetFilePath(profile)
|
||||
filename, err := checkProfileAndGetFilePath(profile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("errore checking profile: %v", err)
|
||||
}
|
||||
content, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return fmt.Errorf("error reading file: %v", err)
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(content, &App); err != nil {
|
||||
return fmt.Errorf("error unmarshaling JSON: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkProfileAndGetFilePath(profile string) string {
|
||||
func checkProfileAndGetFilePath(profile string) (string, error) {
|
||||
var filename string
|
||||
switch {
|
||||
case profile == "dev":
|
||||
@@ -43,7 +44,7 @@ func checkProfileAndGetFilePath(profile string) string {
|
||||
case profile == "prod":
|
||||
filename = fmt.Sprintf("%s/application.json", configDir)
|
||||
default:
|
||||
log.Fatalf("Profile %s is not valid value", profile)
|
||||
return "", fmt.Errorf("profile %s is not valid value", profile)
|
||||
}
|
||||
return filename
|
||||
return filename, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user