https://github.com/jthomas/ow
Utility for running Go language Actions on OpenWhisk
https://github.com/jthomas/ow
Last synced: about 1 month ago
JSON representation
Utility for running Go language Actions on OpenWhisk
- Host: GitHub
- URL: https://github.com/jthomas/ow
- Owner: jthomas
- License: apache-2.0
- Created: 2016-06-21T14:19:50.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-02-12T17:35:27.000Z (over 8 years ago)
- Last Synced: 2025-03-19T10:41:49.133Z (about 1 year ago)
- Language: Go
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ow
Utility for running Go language Actions on OpenWhisk, see [this project](https://github.com/jthomas/openwhisk_go_action).
install
--
```
go get github.com/jthomas/ow
```
usage
--
``` go
package main
import (
"encoding/json"
"github.com/jthomas/ow"
)
type Params struct {
Payload string `json:"payload"`
}
type Result struct {
Reversed string `json:"reversed"`
}
func reverse_string(to_reverse string) string {
chars := []rune(to_reverse)
for i, j := 0, len(chars)-1; i < j; i, j = i+1, j-1 {
chars[i], chars[j] = chars[j], chars[i]
}
return string(chars)
}
func main() {
ow.RegisterAction(func(value json.RawMessage) (interface{}, error) {
var params Params
err := json.Unmarshal(value, ¶ms)
if err != nil {
return nil, err
}
return Result{Reversed: reverse_string(params.Payload)}, nil
})
}
```