-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openapi): add brainx provider hello world
- Loading branch information
Showing
17 changed files
with
455 additions
and
97 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 @@ | ||
// Custom APis |
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,2 +1,5 @@ | ||
import "openapi/auth.api" | ||
import "openapi/demo.api" | ||
import "openapi/demo.api" | ||
|
||
// provider | ||
import "openapi/provider/brainx/demo.api" |
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,27 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "Provider Demo Open API of BrainX" | ||
desc: "This is a api of Open API in Artisan Cloud" | ||
author: "Matrix-X" | ||
email: "[email protected]" | ||
version: "v1" | ||
) | ||
|
||
@server( | ||
group: openapi/provider/brainx | ||
prefix: /openapi/v1/provider/brainx | ||
) | ||
|
||
service PowerX { | ||
@doc "hello world api for provider demo" | ||
@handler HelloWorld | ||
get /hello-world returns (HelloWorldResponse) | ||
} | ||
|
||
|
||
type ( | ||
HelloWorldResponse { | ||
Message string `json:"message"` | ||
} | ||
) |
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 @@ | ||
// Pro APis |
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,7 +1,8 @@ | ||
package openapiprovider | ||
|
||
type BrainX struct { | ||
BaseUrl string | ||
AccessKey string | ||
SecretKey string | ||
BaseUrl string | ||
AccessKey string | ||
SecretKey string | ||
ProviderName string | ||
} |
22 changes: 22 additions & 0 deletions
22
internal/handler/openapi/provider/brainx/helloworldhandler.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,22 @@ | ||
package brainx | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/openapi/provider/brainx" | ||
"PowerX/internal/svc" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
// hello world api for provider demo | ||
func HelloWorldHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
l := brainx.NewHelloWorldLogic(r.Context(), svcCtx) | ||
resp, err := l.HelloWorld() | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Oops, something went wrong.