| "veyron.io/veyron/veyron/services/identity/util" |
| "veyron.io/veyron/veyron2" |
| // Random is an http.Handler implementation that mints a new Veyron PrivateID |
| type Random struct{ Runtime veyron2.Runtime } |
| func (h Random) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| name := fmt.Sprintf("random:%d", rand.Intn(1000)) |
| id, err := h.Runtime.NewIdentity(name) |
| util.HTTPServerError(w, err) |
| // Bless this with the identity of the runtime, valid for 1 hour. |
| blessing, err := h.Runtime.Identity().Bless(id.PublicID(), name, 1*time.Hour, nil) |
| util.HTTPServerError(w, err) |
| id, err = id.Derive(blessing) |
| util.HTTPServerError(w, err) |