Beispiel #1
0
// JSON is a method for actions.JSON
func (action *OperationIndexAction) JSON() {
	action.LoadPage()
	if action.Err != nil {
		return
	}
	hal.Render(action.W, action.Page)
}
// JSON is a method for actions.JSON
func (action *OrderBookShowAction) JSON() {
	action.Do(action.LoadQuery, action.LoadRecord, action.LoadResource)

	action.Do(func() {
		hal.Render(action.W, action.Resource)
	})
}
Beispiel #3
0
// JSON is a method for actions.JSON
func (action *OffersByAccountAction) JSON() {
	action.LoadPage()
	if action.Err != nil {
		return
	}
	hal.Render(action.W, action.Page)
}
Beispiel #4
0
// JSON is a method for actions.JSON
func (action *EffectIndexAction) JSON() {
	action.Do(action.LoadQuery, action.LoadRecords, action.LoadPage)

	action.Do(func() {
		hal.Render(action.W, action.Page)
	})
}
Beispiel #5
0
// JSON is a method for actions.JSON
func (action *AccountShowAction) JSON() {
	action.LoadRecord()
	if action.Err != nil {
		return
	}

	hal.Render(action.W, NewAccountResource(action.Record))
}
Beispiel #6
0
// JSON is a method for actions.JSON
func (action *MetricsAction) JSON() {
	db.UpdateLedgerState(action.Ctx, action.App.HistoryQuery(), action.App.CoreQuery())
	action.LoadSnapshot()
	action.Snapshot["_links"] = map[string]interface{}{
		"self": halgo.Link{Href: "/metrics"},
	}

	hal.Render(action.W, action.Snapshot)
}
Beispiel #7
0
// JSON is a method for actions.JSON
func (action *TradeIndexAction) JSON() {
	action.Do(
		action.LoadQuery,
		action.LoadRecords,
		action.LoadPage,
		func() {
			hal.Render(action.W, action.Page)
		},
	)
}
// JSON is a method for actions.JSON
func (action *TransactionShowAction) JSON() {
	query := action.Query()

	if action.Err != nil {
		return
	}

	action.Err = db.Get(action.Ctx, query, &action.Record)

	if action.Err != nil {
		return
	}

	hal.Render(action.W, NewTransactionResource(action.Record))
}
Beispiel #9
0
func (action *RootAction) JSON() {
	var response = RootResource{
		HorizonVersion:     action.App.horizonVersion,
		StellarCoreVersion: action.App.coreVersion,
		Links: halgo.Links{}.
			Self("/").
			Link("account", "/accounts/{address}").
			Link("account_transactions", "/accounts/{address}/transactions{?cursor,limit,order}").
			Link("transaction", "/transactions/{hash}").
			Link("transactions", "/transactions{?cursor,limit,order}").
			Link("order_book", "/order_book{?selling_asset_type,selling_asset_code,selling_issuer,buying_asset_type,buying_asset_code,buying_issuer}").
			Link("metrics", "/metrics").
			Link("friendbot", "/friendbot{?addr}"),
	}
	hal.Render(action.W, response)
}
Beispiel #10
0
// JSON is a method for actions.JSON
func (action *OperationShowAction) JSON() {
	query := action.Query()
	if action.Err != nil {
		return
	}

	action.Err = db.Get(action.Ctx, query, &action.Record)
	if action.Err != nil {
		return
	}

	r, err := NewOperationResource(action.Record)
	if err != nil {
		return
	}

	hal.Render(action.W, r)
}