generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from BuxOrg/siggi/actions-count
Added missing count actions in http endpoints
- Loading branch information
Showing
6 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package accessKeys | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/BuxOrg/bux" | ||
"github.com/BuxOrg/bux-server/actions" | ||
"github.com/julienschmidt/httprouter" | ||
apirouter "github.com/mrz1836/go-api-router" | ||
) | ||
|
||
// count will fetch a count of access keys filtered by metadata | ||
func (a *Action) count(w http.ResponseWriter, req *http.Request, _ httprouter.Params) { | ||
|
||
reqXPubID, _ := bux.GetXpubIDFromRequest(req) | ||
|
||
// Parse the params | ||
params := apirouter.GetParams(req) | ||
_, metadata, conditions, err := actions.GetQueryParameters(params) | ||
if err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Record a new transaction (get the hex from parameters)a | ||
var count int64 | ||
if count, err = a.Services.Bux.GetAccessKeysByXPubIDCount( | ||
req.Context(), | ||
reqXPubID, | ||
metadata, | ||
conditions, | ||
); err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Return response | ||
apirouter.ReturnResponse(w, req, http.StatusOK, count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package destinations | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/BuxOrg/bux" | ||
"github.com/BuxOrg/bux-server/actions" | ||
"github.com/julienschmidt/httprouter" | ||
apirouter "github.com/mrz1836/go-api-router" | ||
) | ||
|
||
// count will fetch a count of destinations filtered by metadata | ||
func (a *Action) count(w http.ResponseWriter, req *http.Request, _ httprouter.Params) { | ||
|
||
reqXPubID, _ := bux.GetXpubIDFromRequest(req) | ||
|
||
// Parse the params | ||
params := apirouter.GetParams(req) | ||
_, metadata, conditions, err := actions.GetQueryParameters(params) | ||
if err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Record a new transaction (get the hex from parameters)a | ||
var count int64 | ||
if count, err = a.Services.Bux.GetDestinationsByXpubIDCount( | ||
req.Context(), | ||
reqXPubID, | ||
metadata, | ||
conditions, | ||
); err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Return response | ||
apirouter.ReturnResponse(w, req, http.StatusOK, count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package transactions | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/BuxOrg/bux" | ||
"github.com/BuxOrg/bux-server/actions" | ||
"github.com/julienschmidt/httprouter" | ||
apirouter "github.com/mrz1836/go-api-router" | ||
) | ||
|
||
// count will fetch a count of transactions filtered on conditions and metadata | ||
func (a *Action) count(w http.ResponseWriter, req *http.Request, _ httprouter.Params) { | ||
|
||
reqXPubID, _ := bux.GetXpubIDFromRequest(req) | ||
|
||
// Parse the params | ||
params := apirouter.GetParams(req) | ||
_, metadata, conditions, err := actions.GetQueryParameters(params) | ||
if err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Record a new transaction (get the hex from parameters)a | ||
var count int64 | ||
if count, err = a.Services.Bux.GetTransactionsByXpubIDCount( | ||
req.Context(), | ||
reqXPubID, | ||
metadata, | ||
conditions, | ||
); err != nil { | ||
apirouter.ReturnResponse(w, req, http.StatusExpectationFailed, err.Error()) | ||
return | ||
} | ||
|
||
// Return response | ||
apirouter.ReturnResponse(w, req, http.StatusOK, count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters