-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ChaosCenter]: Migrating graphql-server from Gorilla mux to Gin (#3923) #3923
Merged
Merged
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c9c08d3
Migrate from Gorilla mux to Gin
namkyu1999 d6e352d
Linting & Ordering codes
namkyu1999 5369e4b
Merge branch 'master' of https://github.com/litmuschaos/litmus into m…
namkyu1999 26a1619
fix: remove duplicated code
namkyu1999 6c7738a
fix: adopt go fmt
namkyu1999 acba37c
Move to using interface for better mocking at chaoshub package (#3933)
namkyu1999 3493605
fix: status code to constant variable
namkyu1999 9e9377e
fix: add logs when encounterd error
namkyu1999 b5b0b28
fix: rename pkg name
namkyu1999 c20456d
fix: rename pkg, graphql_server to rest_handlers
namkyu1999 464cef0
fix: resolve codeql issue
namkyu1999 04842e5
fix: add replacer value
namkyu1999 001aaf9
Merge branch 'master' of https://github.com/litmuschaos/litmus into m…
namkyu1999 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
@@ -1,29 +1,24 @@ | ||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
"strings" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/gin-gonic/gin" | ||
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/cluster" | ||
"github.com/sirupsen/logrus" | ||
|
||
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/utils" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
// FileHandler dynamically generates the manifest file and sends it as a response | ||
func FileHandler(w http.ResponseWriter, r *http.Request) { | ||
var ( | ||
vars = mux.Vars(r) | ||
token = vars["key"] | ||
) | ||
|
||
func FileHandler(c *gin.Context) { | ||
token := strings.TrimSuffix(c.Param("key"), ".yaml") | ||
response, statusCode, err := cluster.GetManifest(token) | ||
if err != nil { | ||
logrus.WithError(err).Error("error while generating manifest file") | ||
utils.WriteHeaders(&w, statusCode) | ||
w.Write([]byte(err.Error())) | ||
utils.WriteHeaders(&c.Writer, statusCode) | ||
c.Writer.Write([]byte(err.Error())) | ||
} | ||
|
||
utils.WriteHeaders(&w, statusCode) | ||
w.Write(response) | ||
utils.WriteHeaders(&c.Writer, statusCode) | ||
c.Writer.Write(response) | ||
} |
15 changes: 15 additions & 0 deletions
15
litmus-portal/graphql-server/pkg/handlers/playground_handler.go
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,15 @@ | ||
package handlers | ||
namkyu1999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import ( | ||
"github.com/99designs/gqlgen/graphql/playground" | ||
"github.com/gin-gonic/gin" | ||
) | ||
|
||
// PlaygroundHandler returns GraphQL playground ui | ||
func PlaygroundHandler() gin.HandlerFunc { | ||
h := playground.Handler("GraphQL playground", "/query") | ||
|
||
return func(c *gin.Context) { | ||
h.ServeHTTP(c.Writer, c.Request) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.7.7 is released in 2021. Can we use the latest one? If no major code change is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imrajdas let's take it in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.9.0 is the latest version.
But higher than 1.7.7, We need to upgrade the version of Go 1.17.
So I just use that version like the authentication server in litmusChaos
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, lets do it in other PR