1234567891011121314151617181920212223242526272829303132333435363738 |
- package main
- import (
- "flow/registry"
- "flowserver"
- "io/ioutil"
- "math"
- "net/http"
- "strings"
- )
- func main() {
- r := registry.New()
- r.Add("hello", func() string {
- return "hello world"
- })
- r.Add(strings.Split, strings.Join)
- fns := r.Add(math.Exp, math.Sin, math.Cos)
- //Describing groups of functions
- fns.Tags("math")
- fns.Extra("style", registry.M{"color": "#F00"})
- // Describing a function
- registry.Describer(
- r.Add(http.Get).Inputs("url"),
- r.Add(responseReader).Inputs("response"),
- ).Tags("http").Extra("style", registry.M{"color": "#00F"})
- http.ListenAndServe(":5000", flowserver.New(r, "storename"))
- }
- func responseReader(r *http.Response) (string, error) {
- defer r.Body.Close()
- res, err := ioutil.ReadAll(r.Body)
- return string(res), err
- }
|