Permalink
Browse files

Add hello-world services to examples/.

  • Loading branch information...
vlad-alexandru-ionescu committed Jun 3, 2016
1 parent a892919 commit 03979051db78c526d3b7454da659b6b83d335ffd
View
@@ -1,4 +1,5 @@
/repo/
+/examples/*/serve
/services/leveroshost/leveroshost
/services/levercontainer/js/leveros-server/
/services/levercontainer/js/leveros-common/
View
@@ -58,9 +58,12 @@ func main() {
server.Serve()
}
+// Handler is the service handler. Its exported methods become the service's
+// methods.
type Handler struct {
}
+// SayHello returns a salutation for the given name.
func (*Handler) SayHello(name string) (result string, err error) {
return fmt.Sprintf("Hello, %s!", name), nil
}
View
@@ -31,9 +31,12 @@ server.go
server.Serve()
}
+ // Handler is the service handler. Its exported methods become the service's
+ // methods.
type Handler struct {
}
+ // SayHello returns a salutation for the given name.
func (*Handler) SayHello(name string) (result string, err error) {
return fmt.Sprintf("Hello, %s!", name), nil
}
@@ -0,0 +1,12 @@
+helloService in Go
+==================
+
+To run this example
+
+```bash
+$ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./serve server.go
+$ lever deploy
+$ lever invoke /helloService/SayHello '"world"'
+
+"Hello, world!"
+```
@@ -0,0 +1,5 @@
+{
+ "name": "helloService",
+ "description": "A hello service.",
+ "entry": ["./serve"]
+}
@@ -0,0 +1,30 @@
+package main
+
+import (
+ "fmt"
+ "log"
+
+ leverapi "github.com/leveros/leveros/api"
+)
+
+func main() {
+ server, err := leverapi.NewServer()
+ if err != nil {
+ log.Fatalf("Error: %v\n", err)
+ }
+ err = server.RegisterHandlerObject(new(Handler))
+ if err != nil {
+ log.Fatalf("Error: %v\n", err)
+ }
+ server.Serve()
+}
+
+// Handler is the service handler. Its exported methods become the service's
+// methods.
+type Handler struct {
+}
+
+// SayHello returns a salutation for the given name.
+func (*Handler) SayHello(name string) (result string, err error) {
+ return fmt.Sprintf("Hello, %s!", name), nil
+}
@@ -0,0 +1,11 @@
+helloService in JavaScript
+==========================
+
+To run this example
+
+```bash
+$ lever deploy
+$ lever invoke /helloService/sayHello '"world"'
+
+"Hello, world!"
+```
@@ -0,0 +1,5 @@
+{
+ "name": "helloService",
+ "description": "A hello service.",
+ "jsEntry": "server.js"
+}
@@ -0,0 +1,3 @@
+module.exports.sayHello = function (name, callback) {
+ callback(null, "Hello, " + name + "!");
+};

0 comments on commit 0397905

Please sign in to comment.