// NewOpenAccountHandlerFunc creates new account openning endpoint example
NewOpenAccountHandlerFunc creates new account openning endpoint example
// NewOpenAccountHandlerFunc creates new account openning endpoint example
func NewOpenAccountHandlerFunc(store *AccountStore) http.HandlerFunc {
	return func(rw http.ResponseWriter, r *http.Request) {
		id := fmt.Sprintf("%d-%d", time.Now().Unix(), rand.Int())
		acc, err := account.New(id, "John Doe")
		if err != nil {
			fmt.Fprintf(rw, "error: %v", err)
		}
		err = store.Save(r.Context(), acc)
		if err != nil {
			fmt.Fprintf(rw, "error: %v", err)
		}
		fmt.Fprintf(rw, "account created: %s", acc.ID)
	}
}
func NewOpenAccountHandlerFunc ( store * AccountStore ) http . HandlerFunc { return func ( rw http . ResponseWriter , r * http . Request ) { id := fmt . Sprintf ( " " , time . Now ( ) . Unix ( ) , rand . Int ( ) ) acc , err := account . New ( id , " " ) if err != nil { fmt . Fprintf ( rw , " " , err ) } err = store . Save ( r . Context ( ) , acc ) if err != nil { fmt . Fprintf ( rw , " " , err ) } fmt . Fprintf ( rw , " " , acc . ID ) } }
NewOpenAccountHandlerFunc creates new account openning endpoint example
NewOpenAccountHandlerFunc creates new account openning endpoint example