Skip to content

Commit

Permalink
Merge pull request #69 from Spacelocust/fix/swagger
Browse files Browse the repository at this point in the history
Fix / swagger
  • Loading branch information
Spacelocust authored Jul 17, 2024
2 parents 3cf1609 + dba91f0 commit 34c6a3e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: spacelocust/fd-api:latest
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
builder: ${{ steps.buildx.outputs.name }}
push: ${{ github.event_name != 'pull_request' }}
tags: spacelocust/fd-migrations:latest
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
env:
Expand Down
10 changes: 8 additions & 2 deletions api/internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ func NewServer() *http.Server {
log.Fatal(err)
}

docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT"))
docs.SwaggerInfo.Schemes = []string{"http", "https"}
// Set up the Swagger documentation
if os.Getenv("API_ENV") == "production" {
docs.SwaggerInfo.Host = os.Getenv("API_DOMAIN")
docs.SwaggerInfo.Schemes = []string{"https"}
} else {
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT"))
docs.SwaggerInfo.Schemes = []string{"http"}
}

// Declare Server config
server := &http.Server{
Expand Down
14 changes: 0 additions & 14 deletions api/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package main

import (
"fmt"
"os"

_ "ariga.io/atlas-provider-gorm/gormschema"
"github.com/Spacelocust/for-democracy/cmd"
"github.com/Spacelocust/for-democracy/docs"
)

// @BasePath /
Expand All @@ -19,15 +15,5 @@ import (
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
func main() {

// Set up the Swagger documentation
if os.Getenv("API_ENV") == "production" {
docs.SwaggerInfo.Host = os.Getenv("API_DOMAIN")
docs.SwaggerInfo.Schemes = []string{"https"}
} else {
docs.SwaggerInfo.Host = fmt.Sprintf("%s:%s", os.Getenv("API_DOMAIN"), os.Getenv("API_PORT"))
docs.SwaggerInfo.Schemes = []string{"http"}
}

cmd.RunCLI()
}

0 comments on commit 34c6a3e

Please sign in to comment.