Skip to content
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

feat(impl): supports data type in response #11 #15

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions example/golang/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"fmt"
"log"

"github.com/isaqueveras/juazeiro"
Expand Down Expand Up @@ -58,6 +59,13 @@ func main() {
}
show(biometryData)

newID, err := repoBio.Create(context.Background(), biometryData)
if err != nil {
handling(err)
return
}
fmt.Printf("newID: %v\n", *newID)

if err = repoUser.EditUser(context.Background(), input); err != nil {
handling(err)
return
Expand Down
8 changes: 2 additions & 6 deletions example/golang/protos/biometry/biometry.juaz
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ node biometry {
state: state
}

node identifier {
id: string
}

node biometry_params {
id: string
document: string
Expand All @@ -35,9 +31,9 @@ node search_params {
parameters: biometry_params
}

impl create(biometry) identifier {
impl create(biometry) string {
method: "POST"
uri: "/v1/biometry/create"
uri: "/v1/biometry"
status: "201"
}

Expand Down
13 changes: 4 additions & 9 deletions example/golang/protos/biometry/biometry.juaz_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions example/golang/server/hander.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,7 @@ func obtain_biometry(ctx *gin.Context) {

ctx.JSON(http.StatusOK, body)
}

func create_biometry(ctx *gin.Context) {
ctx.JSON(http.StatusCreated, "4f68accd-a754-4218-91f6-b9e6c0fe8da7")
}
2 changes: 2 additions & 0 deletions example/golang/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ func main() {
router := gin.Default()

router.GET("/v1/user/:id", getUser)

router.GET("/v1/biometry/search", search_biometry)
router.GET("/v1/biometry/obtain/:id", obtain_biometry)
router.POST("/v1/biometry", create_biometry)

router.Run(":8181")
}
4 changes: 4 additions & 0 deletions golang/build_implement_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ func _build_implement_method(juaz *grammar.Juaz) string {

if value.Impl.Output != nil {
reference := strcase.ToCamel(value.Impl.Output.Reference)
if value.Impl.Output.Scalar != 0 {
reference = value.Impl.Output.Scalar.GoString()
}

if value.Impl.Repeated {
reference = fmt.Sprintf("[]%s", reference)
}
Expand Down
4 changes: 4 additions & 0 deletions golang/build_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func _build_interface_methods(juaz *grammar.Juaz) string {
if value.Impl != nil {
if value.Impl.Output != nil {
reference := strcase.ToCamel(value.Impl.Output.Reference)
if value.Impl.Output.Scalar != 0 {
reference = value.Impl.Output.Scalar.GoString()
}

if value.Impl.Repeated {
reference = fmt.Sprintf("[]%s", reference)
}
Expand Down