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

WebRPCServicesMap - helper variable #69

Closed
wants to merge 2 commits into from
Closed
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
13 changes: 12 additions & 1 deletion _examples/golang-basics/example.gen.go

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

10 changes: 9 additions & 1 deletion _examples/golang-imports/api.gen.go

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

7 changes: 3 additions & 4 deletions _examples/golang-imports/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func startServer() error {
return http.ListenAndServe(":4242", r)
}

type ExampleRPC struct {
}
type ExampleRPC struct{}

func (s *ExampleRPC) Ping(ctx context.Context) error {
return nil
Expand All @@ -44,9 +43,9 @@ func (s *ExampleRPC) Status(ctx context.Context) (bool, error) {
return true, nil
}

func (s *ExampleRPC) GetUsers(ctx context.Context) ([]*User, *Location, error) {
func (s *ExampleRPC) GetUsers(ctx context.Context) ([]*User, Location, error) {
loc := Location_TORONTO
return []*User{
{Username: "pk", Age: 99},
}, &loc, nil
}, loc, nil
}
10 changes: 10 additions & 0 deletions types.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ var WebRPCServices = map[string][]string{
{{- end}}
}

type Route struct{}

var WebRPCServicesMap = map[string]Route{
{{- range $_, $service := $services}}
{{- range $_, $method := $service.Methods}}
"/rpc/{{$service.Name}}/{{$method.Name}}": {},
{{- end}}
{{- end}}
}

//
// Server types
//
Expand Down
Loading