Fix configurations

This commit is contained in:
Fabio Scotto di Santolo
2025-06-01 13:00:00 +02:00
parent 1a5d437311
commit 0c17486015
12 changed files with 33 additions and 88 deletions

43
.gitignore vendored
View File

@@ -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
View File

@@ -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

View File

@@ -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>

View File

@@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

View File

@@ -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
View File

@@ -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
View File

@@ -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
View File

@@ -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>

View File

@@ -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 {

View File

@@ -1,6 +1,6 @@
{
"server": {
"host": "localhost",
"port": 8080
"port": 8081
}
}

View File

@@ -1,6 +1,6 @@
{
"server": {
"host": "localhost",
"port": 8089
"port": 8080
}
}

View File

@@ -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
}