-
Notifications
You must be signed in to change notification settings - Fork 1
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 #5 from jerry-enebeli/feature/service
Feature/service
- Loading branch information
Showing
10 changed files
with
591 additions
and
17 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,7 @@ | ||
package main | ||
|
||
import "github.com/jerry-enebeli/grpc-rest-gateway/cmd/gateway" | ||
|
||
func main() { | ||
gateway.Execute() | ||
} |
This file was deleted.
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,73 @@ | ||
package gateway | ||
|
||
import ( | ||
"fmt" | ||
"github.com/jerry-enebeli/grpc-rest-gateway/pkg/service" | ||
"github.com/jerry-enebeli/grpc-rest-gateway/tools" | ||
"github.com/spf13/cobra" | ||
"log" | ||
"os" | ||
) | ||
|
||
var sourceProtoFile string | ||
|
||
var s = service.NewService() | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "Gateway", | ||
Short: "gRPC to REST", | ||
Long: `Gateway is a api gateway for gRPC application. gateway maps RESTFUL API to gRPC services.Complete documentation is available at https://github.com/jerry-enebeli/grpc-rest-gateway`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
output, _ := tools.Shell("bash", "gateway --help") | ||
|
||
log.Println(output) | ||
}, | ||
} | ||
|
||
var serviceCmd = &cobra.Command{ | ||
Use: "service", | ||
Short: "manages gRPC services", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("got this", args) | ||
}, | ||
} | ||
|
||
var serviceListCmd = &cobra.Command{ | ||
Use: "list", | ||
Short: "list gRPC services", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
s.GetAllServices() | ||
}, | ||
} | ||
|
||
var serviceListMethodsCmd = &cobra.Command{ | ||
Use: "list-methods", | ||
Short: "list gRPC services methods", | ||
Example: "Gateway service list-methods [service name]", | ||
ValidArgs: []string{"test"}, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
s.GetServiceMethods(args[0]) | ||
}, | ||
} | ||
|
||
var serviceCreateCmd = &cobra.Command{ | ||
Use: "create", | ||
Short: "create new gRPC services", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
s.CreateService(sourceProtoFile) | ||
}, | ||
} | ||
|
||
func addServiceCreateFlags() { | ||
serviceCreateCmd.Flags().StringVarP(&sourceProtoFile, "source", "s", "", "Source directory to read proto file from") | ||
} | ||
|
||
func Execute() { | ||
addServiceCreateFlags() | ||
serviceCmd.AddCommand(serviceCreateCmd, serviceListCmd, serviceListMethodsCmd) | ||
rootCmd.AddCommand(serviceCmd) | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} |
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,53 @@ | ||
// Copyright 2015, Google Inc. | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions are | ||
// met: | ||
// | ||
// * Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// * Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following disclaimer | ||
// in the documentation and/or other materials provided with the | ||
// distribution. | ||
// * Neither the name of Google Inc. nor the names of its | ||
// contributors may be used to endorse or promote products derived from | ||
// this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "io.grpc.examples.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
|
||
package platphom; | ||
|
||
// The greeting service definition. | ||
service User { | ||
// Sends a greeting | ||
rpc Login (HelloRequest) returns (HelloReply) {} | ||
rpc Signup (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
// The request message containing the user's name. | ||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
// The response message containing the greetings | ||
message HelloReply { | ||
string message = 1; | ||
} |
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
Oops, something went wrong.