예제 #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)
}
예제 #2
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)
}
예제 #3
0
// 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)
	})
}
예제 #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)
	})
}
예제 #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))
}
예제 #6
0
// JSON is a method for actions.JSON
func (action *TransactionShowAction) JSON() {
	action.Do(
		action.LoadQuery,
		action.LoadRecord,
		action.LoadResource,
		func() { hal.Render(action.W, action.Resource) },
	)
}
예제 #7
0
// JSON is a method for actions.JSON
func (action *TransactionShowAction) JSON() {
	action.Do(
		action.loadParams,
		action.loadRecord,
		action.loadResource,
		func() { hal.Render(action.W, action.Resource) },
	)
}
예제 #8
0
// JSON is a method for actions.JSON
func (action *LedgerIndexAction) JSON() {
	action.Do(
		action.LoadQuery,
		action.LoadRecords,
		action.LoadPage,
		func() { hal.Render(action.W, action.Page) },
	)
}
예제 #9
0
// JSON is a method for actions.JSON
func (action *AccountIndexAction) JSON() {
	action.Do(
		action.loadParams,
		action.loadRecords,
		action.loadPage,
		func() { hal.Render(action.W, action.Page) },
	)
}
예제 #10
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)
}
예제 #11
0
// JSON is a method for actions.JSON
func (action *MetricsAction) JSON() {
	action.App.UpdateMetrics(action.Ctx)
	action.LoadSnapshot()
	action.Snapshot["_links"] = map[string]interface{}{
		"self": halgo.Link{Href: "/metrics"},
	}

	hal.Render(action.W, action.Snapshot)
}
예제 #12
0
// JSON format action handler
func (action *TransactionCreateAction) JSON() {
	action.Do(
		action.LoadTX,
		action.LoadResult,
		action.LoadResource,

		func() {
			hal.Render(action.W, action.Resource)
		})
}
예제 #13
0
// JSON is a method for actions.JSON
func (action *OffersByAccountAction) JSON() {
	action.Do(
		action.LoadQuery,
		action.LoadRecords,
		action.LoadPage,
		func() {
			hal.Render(action.W, action.Page)
		},
	)
}
예제 #14
0
// JSON implements actions.JSON
func (action *PathIndexAction) JSON() {
	action.Do(
		action.loadQuery,
		action.loadSourceAssets,
		action.loadRecords,
		action.loadPage,
		func() {
			hal.Render(action.W, action.Page)
		},
	)
}
예제 #15
0
// JSON is a method for actions.JSON
func (action *LedgerShowAction) JSON() {
	action.Do(
		action.LoadQuery,
		action.LoadRecord,
		func() {
			var res resource.Ledger
			res.Populate(action.Ctx, action.Record)
			hal.Render(action.W, res)
		},
	)
}
예제 #16
0
// JSON renders the json response for RootAction
func (action *RootAction) JSON() {
	var res resource.Root
	res.Populate(
		action.Ctx,
		action.App.latestLedgerState,
		action.App.horizonVersion,
		action.App.coreVersion,
	)

	hal.Render(action.W, res)
}
예제 #17
0
// JSON is a method for actions.JSON
func (action *FriendbotAction) JSON() {

	action.Do(
		action.CheckEnabled,
		action.LoadAddress,
		action.LoadResult,
		action.LoadResource,

		func() {
			hal.Render(action.W, action.Resource)
		})
}
예제 #18
0
// JSON is a method for actions.JSON
func (action *DataShowAction) JSON() {
	action.Do(
		action.loadParams,
		action.loadRecord,
		func() {

			hal.Render(action.W, map[string]string{
				"value": action.Data.Value,
			})
		},
	)
}
예제 #19
0
// JSON renders the json response for RootAction
func (action *RootAction) JSON() {
	action.App.UpdateStellarCoreInfo()

	var res resource.Root
	res.Populate(
		action.Ctx,
		action.App.latestLedgerState.Horizon,
		action.App.latestLedgerState.Core,
		action.App.horizonVersion,
		action.App.coreVersion,
		action.App.networkPassphrase,
	)

	hal.Render(action.W, res)
}
예제 #20
0
// JSON is a method for actions.JSON
func (action *LedgerShowAction) 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, NewLedgerResource(action.Record))
}
예제 #21
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)
}
예제 #22
0
// JSON format action handler
func (action *TransactionCreateAction) JSON() {

	l := action.App.submitter.Submit(action.Ctx, action.GetString("tx"))

	select {
	case result := <-l:
		resource := &ResultResource{result}

		if resource.IsSuccess() {
			hal.Render(action.W, resource.Success())
		} else {
			problem.Render(action.Ctx, action.W, resource.Error())
		}
	case <-action.Ctx.Done():
		return
	}

}
예제 #23
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)
}
예제 #24
0
// JSON is a method for actions.JSON
func (action *OperationShowAction) JSON() {
	action.Do(action.loadParams, action.loadRecord, action.loadResource)
	action.Do(func() {
		hal.Render(action.W, action.Resource)
	})
}
예제 #25
0
// JSON is a method for actions.JSON
func (action *PaymentsIndexAction) JSON() {
	action.Do(action.loadParams, action.loadRecords, action.loadPage)
	action.Do(func() {
		hal.Render(action.W, action.Page)
	})
}