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
package main | |
import ( | |
"fmt" | |
_ "github.com/micro/go-plugins/registry/etcd" | |
"github.com/micro/go-micro/registry" | |
"github.com/micro/go-micro/cmd" | |
) | |
func main() { |
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
package main | |
import ( | |
"crypto/rand" | |
"encoding/hex" | |
"fmt" | |
) | |
func newUUID() string { | |
uuid := make([]byte, 16) |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
"sync" | |
"time" | |
) | |
func foo(w http.ResponseWriter, r *http.Request) { |
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
package main | |
import ( | |
"fmt" | |
"log" | |
"time" | |
"github.com/micro/go-micro/broker" | |
"github.com/micro/go-micro/cmd" | |
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
package main | |
import ( | |
"log" | |
"github.com/micro/go-micro" | |
"github.com/micro/foo/handler" | |
"github.com/micro/foo/subscriber" | |
example "github.com/micro/foo/proto/example" |
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
package main | |
import ( | |
"fmt" | |
"github.com/micro/go-micro/client" | |
store "github.com/micro/kv-srv/proto/store" | |
"golang.org/x/net/context" | |
) |
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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"io/ioutil" | |
"fmt" | |
"net/http" | |
"time" |
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
package main | |
import ( | |
"time" | |
"github.com/micro/go-micro/client" | |
example "github.com/micro/micro/examples/template/srv/proto/example" | |
"golang.org/x/net/context" | |
) |
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
package main | |
import ( | |
"time" | |
"github.com/micro/go-micro/cmd" | |
"github.com/micro/go-micro/client" | |
example "github.com/micro/micro/examples/template/srv/proto/example" | |
"golang.org/x/net/context" | |
) |
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
func permWrapper(perms map[string][]string) server.HandlerWrapper { | |
return func(fn server.HandlerFunc) server.HandlerFunc { | |
return func(ctx context.Context, req server.Request, rsp interface{}) error { | |
md, ok := metadata.FromContext(ctx) | |
if !ok { | |
// just exec | |
return fn(ctx, req, rsp) | |
} | |
role := md["role"] | |
// check roles |