Skip to content

Instantly share code, notes, and snippets.

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() {
@asim
asim / uuid.go
Created January 30, 2016 23:49
UUID gen
package main
import (
"crypto/rand"
"encoding/hex"
"fmt"
)
func newUUID() string {
uuid := make([]byte, 16)
package main
import (
"fmt"
"net/http"
"sync"
"time"
)
func foo(w http.ResponseWriter, r *http.Request) {
package main
import (
"fmt"
"log"
"time"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/cmd"
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"
package main
import (
"fmt"
"github.com/micro/go-micro/client"
store "github.com/micro/kv-srv/proto/store"
"golang.org/x/net/context"
)
package main
import (
"bytes"
"encoding/json"
"io/ioutil"
"fmt"
"net/http"
"time"
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"
)
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"
)
@asim
asim / foo.go
Created October 16, 2016 15:13
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