1 package main
 2 
 3 import (
 4   "flow/registry"
 5   "flowserver"
 6   "io/ioutil"
 7   "log"
 8   "math"
 9   "net/http"
10   "strings"
11 )
12 
13 func main() {
14 
15   r := registry.New()
16   r.Register("hello", func() string {
17     return "hello world"
18   })
19   r.Add(strings.Split, strings.Join)
20 
21   fns, err := r.Add(math.Exp, math.Sin, math.Cos)
22   if err != nil {
23     log.Fatal(err)
24   }
25   //Describing groups of functions
26   fns.Tags("math")
27   fns.Extra("style", registry.M{"color": "#F00"})
28 
29   // Describing a function
30   registry.Describer(
31     r.MustAdd(http.Get).Inputs("url"),
32     r.MustAdd(responseReader).Inputs("response"),
33   ).Tags("http").Extra("style", registry.M{"color": "#00F"})
34 
35   http.ListenAndServe(":5000", flowserver.New(r, "storename"))
36 
37 }
38 func responseReader(r *http.Response) (string, error) {
39   defer r.Body.Close()
40   res, err := ioutil.ReadAll(r.Body)
41   return string(res), err
42 }