-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add swagger Signed-off-by: Thomas Poignant <[email protected]> * add sponsors link Signed-off-by: Thomas Poignant <[email protected]> --------- Signed-off-by: Thomas Poignant <[email protected]>
- Loading branch information
1 parent
9e2a73d
commit ae8c197
Showing
18 changed files
with
1,707 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# These are supported funding model platforms | ||
github: thomaspoignant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: "Lint PR title" | ||
|
||
on: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
main: | ||
permissions: | ||
# for amannn/action-semantic-pull-request to analyze PR titles | ||
# for marocchino/sticky-pull-request-comment to add comments to the PR | ||
pull-requests: write | ||
statuses: write # for amannn/action-semantic-pull-request to mark status of analyzed PR | ||
name: Validate PR title | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: amannn/action-semantic-pull-request@v5 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: marocchino/sticky-pull-request-comment@v2 | ||
# When the previous steps fails, the workflow would stop. By adding this | ||
# condition you can continue the execution with the populated error message. | ||
if: always() && (steps.lint_pr_title.outputs.error_message != null) | ||
with: | ||
header: pr-title-lint-error | ||
message: | | ||
Hey there and thank you for opening this pull request! 👋🏼 | ||
We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted. | ||
Details: | ||
``` | ||
${{ steps.lint_pr_title.outputs.error_message }} | ||
``` | ||
# Delete a previous comment when the issue has been resolved | ||
- if: ${{ steps.lint_pr_title.outputs.error_message == null }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: pr-title-lint-error | ||
delete: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package api | ||
|
||
import ( | ||
_ "github.com/go-feature-flag/app-api/docs" | ||
"github.com/go-feature-flag/app-api/handler" | ||
"github.com/labstack/echo/v4" | ||
"github.com/labstack/echo/v4/middleware" | ||
"github.com/swaggo/echo-swagger" | ||
) | ||
|
||
// New creates a new instance of the API server | ||
func New(serverAddress string, flagHandlers handler.Flags) *Server { | ||
return &Server{ | ||
flagHandlers: flagHandlers, | ||
apiEcho: echo.New(), | ||
serverAddress: serverAddress, | ||
} | ||
} | ||
|
||
// Server is the struct that represents the API server | ||
type Server struct { | ||
flagHandlers handler.Flags | ||
apiEcho *echo.Echo | ||
serverAddress string | ||
} | ||
|
||
// Start starts the API server | ||
func (s *Server) Start() { | ||
// config echo | ||
s.apiEcho.HideBanner = true | ||
s.apiEcho.HidePort = true | ||
|
||
// Middlewares | ||
s.apiEcho.Use(middleware.CORSWithConfig(middleware.DefaultCORSConfig)) | ||
|
||
// init API routes | ||
groupV1 := s.apiEcho.Group("/v1") | ||
groupV1.GET("/flags", s.flagHandlers.GetAllFeatureFlags) | ||
groupV1.GET("/flags/:id", s.flagHandlers.GetFeatureFlagsByID) | ||
groupV1.POST("/flags", s.flagHandlers.CreateNewFlag) | ||
groupV1.PUT("/flags/:id", s.flagHandlers.UpdateFlagByID) | ||
groupV1.DELETE("/flags/:id", s.flagHandlers.DeleteFlagByID) | ||
groupV1.PATCH("/flags/:id/status", s.flagHandlers.UpdateFeatureFlagStatus) | ||
|
||
// TODO: conditionally enable swagger based on configuration | ||
s.apiEcho.GET("/swagger/*", echoSwagger.WrapHandler) | ||
|
||
// start the server | ||
s.apiEcho.Logger.Fatal(s.apiEcho.Start(s.serverAddress)) | ||
} | ||
|
||
// Stop stops the API server | ||
func (s *Server) Stop() error { | ||
return s.apiEcho.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Introduction | ||
|
||
This API is documented in **OpenAPI format** and describe the REST API of the **`GO Feature Flag configuration API`**. | ||
|
||
The goal of this micro-service is to offer a way to configure your feature flags in a more centralized and convenient way than a file. |
Oops, something went wrong.