-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #477 from kube-tarian/agent-gin-fw-rest-server
Agent gin fw rest server
- Loading branch information
Showing
13 changed files
with
618 additions
and
203 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
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,6 @@ | ||
package: api | ||
generate: | ||
gin-server: true | ||
models: true | ||
embedded-spec: true | ||
output: agent/gin-api-server/api/agent.gen.go |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,19 @@ | ||
package ginapiserver | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/intelops/go-common/logging" | ||
"github.com/kube-tarian/kad/capten/agent/gin-api-server/api" | ||
"github.com/kube-tarian/kad/capten/agent/internal/config" | ||
) | ||
|
||
var log = logging.NewLogger() | ||
|
||
func StartRestServer(rpcapi api.ServerInterface, cfg *config.SericeConfig) { | ||
r := gin.Default() | ||
api.RegisterHandlers(r, rpcapi) | ||
|
||
r.Run(fmt.Sprintf("%s:%d", cfg.Host, cfg.RestPort)) | ||
} |
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,17 @@ | ||
package api | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
api "github.com/kube-tarian/kad/capten/agent/gin-api-server/api" | ||
) | ||
|
||
// open api swagger documentation | ||
func (a *Agent) GetApiDocs(c *gin.Context) { | ||
apiDocs, err := api.GetSwagger() | ||
if err != nil { | ||
c.String(http.StatusInternalServerError, err.Error()) | ||
} | ||
c.IndentedJSON(http.StatusOK, apiDocs) | ||
} |
Oops, something went wrong.