Skip to content

Commit

Permalink
Simplifying
Browse files Browse the repository at this point in the history
  • Loading branch information
Dokotela committed Nov 20, 2024
1 parent c7aa178 commit 9b3e9ff
Showing 1 changed file with 8 additions and 63 deletions.
71 changes: 8 additions & 63 deletions pocketfhir/caddy.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func generateStorageConfig(storagePath string) string {

// Generates the HTTP application configuration section
func generateHttpAppConfig(pbPort, httpPort, httpsPort, pbUrl, rootCertPath, ipAddress string) string {
httpServerConfig := generateHttpServerConfig(httpPort, ipAddress, rootCertPath)
httpServerConfig := generateHttpServerConfig(httpPort, ipAddress)
httpsServerConfig := generateHttpsServerConfig(httpsPort, ipAddress, pbUrl, pbPort)
return fmt.Sprintf(`"http": {
"http_port": %s,
Expand All @@ -138,72 +138,22 @@ func generateHttpAppConfig(pbPort, httpPort, httpsPort, pbUrl, rootCertPath, ipA
}`, httpPort, httpServerConfig, httpsServerConfig)
}

// Generates the HTTP server configuration
func generateHttpServerConfig(httpPort, ipAddress, rootCertPath string) string {
// Generates the HTTP server configuration without static file server handling
func generateHttpServerConfig(httpPort, ipAddress string) string {
return fmt.Sprintf(`"srv1": {
"listen": [":%s"],
"routes": [
{
"match": [{"host": ["%s"]}],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "vars",
"root": "%s"
}
]
},
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "rewrite",
"strip_path_prefix": "/certs"
}
]
},
{
"handle": [
{
"browse": {},
"handler": "file_server",
"hide": [
"./Caddyfile.fhirant"
]
}
]
}
]
}
],
"match": [
{
"path": ["/certs/*"]
}
]
}
]
"handler": "subroute"
}
],
"terminal": true
}
],
"logs": {
"logger_names": {
"%s": [
"certs"
]
}
}
}`, httpPort, ipAddress, rootCertPath, ipAddress)
]
}`, httpPort, ipAddress)
}

// Generates the HTTPS server configuration
Expand Down Expand Up @@ -236,13 +186,8 @@ func generateHttpsServerConfig(httpsPort, ipAddress, pbUrl, pbPort string) strin
}
]
}
],
"logs": {
"logger_names": {
"%s": ["log1"]
}
}
}`, httpsPort, ipAddress, pbUrl, pbPort, ipAddress)
]
}`, httpsPort, ipAddress, pbUrl, pbPort)
}

// Generates the TLS automation configuration
Expand Down

0 comments on commit 9b3e9ff

Please sign in to comment.