예제 #1
0
// JSON is a method for actions.JSON
func (action *AccountIndexAction) 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 *OrderBookShowAction) JSON() {
	action.Do(action.LoadQuery, action.LoadRecord, action.LoadResource)

	action.Do(func() {
		hal.Render(action.W, action.Resource)
	})
}
예제 #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)
}
예제 #4
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))
}
예제 #5
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)
}
예제 #6
0
// 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))
}
예제 #7
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)
}
예제 #8
0
func rootAction(w http.ResponseWriter, r *http.Request) {
	hal.Render(w, globalRootResource)
}