Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pacedotdev/oto
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.4.1
Choose a base ref
...
head repository: pacedotdev/oto
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.5.0
Choose a head ref
  • 8 commits
  • 17 files changed
  • 2 contributors

Commits on Jul 15, 2020

  1. started extracting comments

    matryer committed Jul 15, 2020
    Copy the full SHA
    f2193a4 View commit details
  2. Copy the full SHA
    c9e8aa3 View commit details
  3. Copy the full SHA
    987a809 View commit details
  4. updated comments

    matryer committed Jul 15, 2020
    Copy the full SHA
    fc7e086 View commit details
  5. Copy the full SHA
    7b8935c View commit details
  6. added comments to examples

    matryer committed Jul 15, 2020
    Copy the full SHA
    f8ca92e View commit details
  7. Merge branch 'comments'

    dahernan committed Jul 15, 2020
    Copy the full SHA
    eff6fbe View commit details
  8. upgraded

    matryer committed Jul 15, 2020
    Copy the full SHA
    b42cf00 View commit details
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -21,15 +21,21 @@ Create a project folder, and write your service definition as a Go interface:
// definitions/definitons.go
package definitions

// GreeterService makes nice greetings.
type GreeterService interface {
// Greet makes a greeting.
Greet(GreetRequest) GreetResponse
}

// GreetRequest is the request object for GreeterService.Greet.
type GreetRequest struct {
// Name is the person to greet.
Name string
}

// GreetResponse is the response object for GreeterService.Greet.
type GreetResponse struct {
// Greeting is the greeting that was generated.
Greeting string
}
```
@@ -45,17 +51,17 @@ mkdir templates \
Use the `oto` tool to generate a client and server:

```bash
mkdir generated &&
mkdir generated
oto -template ./templates/server.go.plush \
-out ./generated/oto.gen.go \
-ignore Ignorer \
-pkg generated \
./definitions/definitions.go &&
gofmt -w ./generated/oto.gen.go ./generated/oto.gen.go &&
./path/to/definition
gofmt -w ./generated/oto.gen.go ./generated/oto.gen.go
oto -template ./templates/client.js.plush \
-out ./generated/oto.gen.js \
-ignore Ignorer \
./definitions/definitions.go
./path/to/definition
```

- Run `oto -help` for more information about these flags
@@ -115,7 +121,7 @@ oto \
-template ./templates/server.go.plush \
-out ./generated/oto.gen.go \
-params "key1:value1,key2:value2" \
./definitions/definitions.go
./path/to/definition
```

Within your templates, you may access these strings with `<%= params["key1"] %>`.
3 changes: 3 additions & 0 deletions example/def/greeter_service.go
Original file line number Diff line number Diff line change
@@ -5,11 +5,14 @@ type GreeterService interface {
Greet(GreetRequest) GreetResponse
}

// GreetRequest is the request object for GreeterService.Greet.
type GreetRequest struct {
// Name is the person to greet.
// It is required.
Name string
}

// GreetResponse is the response object for GreeterService.Greet.
type GreetResponse struct {
// Greeting is a nice message welcoming somebody.
Greeting string
5 changes: 4 additions & 1 deletion example/go.mod
Original file line number Diff line number Diff line change
@@ -2,4 +2,7 @@ module github.com/pacedotdev/oto/example2

go 1.14

require github.com/pacedotdev/oto/otohttp v0.3.0
require (
github.com/pacedotdev/oto/otohttp v0.4.1
github.com/pkg/errors v0.9.1 // indirect
)
9 changes: 6 additions & 3 deletions example/go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
github.com/pacedotdev/oto v0.3.0 h1:ZtwT3ImKVan6mzXo8q1Tdyu7RzpB2DAhDzYjHQA+HeE=
github.com/pacedotdev/oto/otohttp v0.3.0 h1:ZbykCnQ4JYaei8COdd42gQAvlhtZxnQqpptPx7Ncl+Y=
github.com/pacedotdev/oto/otohttp v0.3.0/go.mod h1:e03n82JQJNrKE3qQdPCwPkgFi3Ss7Us6ij2Jc0RHa0w=
github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE=
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
github.com/pacedotdev/oto/otohttp v0.4.1 h1:tIkVdqUbuRbL910Ism/RybvfPTlbwphUifTn0v8OgUs=
github.com/pacedotdev/oto/otohttp v0.4.1/go.mod h1:q4aoy0cXmEt8FzXXvwJ+Gr21OxAestUIj9fTnb6znDs=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
9 changes: 8 additions & 1 deletion example/server.gen.go

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

7 changes: 4 additions & 3 deletions example/server.go.plush
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import (
)

<%= for (service) in def.Services { %>
type <%= service.Name %> interface {
<%= format_comment_text(service.Comment) %>type <%= service.Name %> interface {
<%= for (method) in service.Methods { %>
<%= method.Name %>(context.Context, <%= method.InputObject.TypeName %>) (*<%= method.OutputObject.TypeName %>, error)<% } %>
}
@@ -26,6 +26,7 @@ type <%= camelize_down(service.Name) %>Server struct {
<%= camelize_down(service.Name) %> <%= service.Name %>
}

// Register adds the <%= service.Name %> to the otohttp.Server.
func Register<%= service.Name %>(server *otohttp.Server, <%= camelize_down(service.Name) %> <%= service.Name %>) {
handler := &<%= camelize_down(service.Name) %>Server{
server: server,
@@ -55,8 +56,8 @@ func (s *<%= camelize_down(service.Name) %>Server) handle<%= method.Name %>(w ht
<% } %>

<%= for (object) in def.Objects { %>
type <%= object.Name %> struct {
<%= for (field) in object.Fields { %><%= field.Name %> <%= if (field.Type.Multiple == true) { %>[]<% } %><%= field.Type.TypeName %> `json:"<%= camelize_down(field.Name) %><%= if (field.OmitEmpty) { %>,omitempty<% } %>"`
<%= format_comment_text(object.Comment) %>type <%= object.Name %> struct {
<%= for (field) in object.Fields { %><%= format_comment_text(field.Comment) %><%= field.Name %> <%= if (field.Type.Multiple == true) { %>[]<% } %><%= field.Type.TypeName %> `json:"<%= camelize_down(field.Name) %><%= if (field.OmitEmpty) { %>,omitempty<% } %>"`
<% } %>
}
<% } %>
10 changes: 1 addition & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -9,21 +9,13 @@ require (
github.com/gobuffalo/helpers v0.6.1 // indirect
github.com/gobuffalo/plush v3.8.3+incompatible
github.com/gobuffalo/tags v2.1.7+incompatible // indirect
github.com/gobuffalo/uuid v2.0.5+incompatible // indirect
github.com/gobuffalo/validate v2.0.4+incompatible // indirect
github.com/gobuffalo/validate/v3 v3.3.0 // indirect
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/golang/protobuf v1.3.1 // indirect
github.com/markbates/inflect v1.0.4
github.com/matryer/is v1.2.0
github.com/matryer/is v1.4.0
github.com/microcosm-cc/bluemonday v1.0.3 // indirect
github.com/onsi/ginkgo v1.10.1 // indirect
github.com/onsi/gomega v1.7.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.6.0 // indirect
github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516 // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/tools v0.0.0-20200714190737-9048b464a08d
)

Loading