Browse Source

Code cleanup

master
Jared 1 year ago
parent
commit
2fae115b2d
9 changed files with 23 additions and 26 deletions
  1. +3
    -2
      auth/auth.go
  2. +3
    -2
      endpoints/contribute.go
  3. +2
    -1
      endpoints/escalateprivileges.go
  4. +3
    -2
      endpoints/getbalance.go
  5. +3
    -2
      endpoints/getqueues.go
  6. +3
    -2
      endpoints/register.go
  7. +3
    -2
      endpoints/users.go
  8. +0
    -11
      helpers.go
  9. +3
    -2
      main.go

+ 3
- 2
auth/auth.go View File

@@ -2,10 +2,11 @@ package auth


import ( import (
"fmt" "fmt"
"github.com/golang-jwt/jwt/v4"
"github.com/spf13/viper"
"net/http" "net/http"
"strings" "strings"

"github.com/golang-jwt/jwt/v4"
"github.com/spf13/viper"
) )


type Claims struct { type Claims struct {


+ 3
- 2
endpoints/contribute.go View File

@@ -3,14 +3,15 @@ package endpoints
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http"
"strings"

. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/keypair" "github.com/stellar/go/keypair"
"github.com/stellar/go/network" "github.com/stellar/go/network"
"github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon"
"github.com/stellar/go/txnbuild" "github.com/stellar/go/txnbuild"
"net/http"
"strings"
) )


type ContributeRequest struct { type ContributeRequest struct {


+ 2
- 1
endpoints/escalateprivileges.go View File

@@ -2,9 +2,10 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
"net/http"

"github.com/imosed/signet/auth" "github.com/imosed/signet/auth"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"net/http"
) )


type EscalatePrivilegesRequest struct { type EscalatePrivilegesRequest struct {


+ 3
- 2
endpoints/getbalance.go View File

@@ -2,11 +2,12 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
"net/http"
"strconv"

"github.com/stellar/go/clients/horizonclient" "github.com/stellar/go/clients/horizonclient"
"github.com/stellar/go/keypair" "github.com/stellar/go/keypair"
"github.com/stellar/go/protocols/horizon" "github.com/stellar/go/protocols/horizon"
"net/http"
"strconv"
) )


type GetBalanceRequest struct { type GetBalanceRequest struct {


+ 3
- 2
endpoints/getqueues.go View File

@@ -2,15 +2,16 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
. "github.com/imosed/signet/data"
"net/http" "net/http"

. "github.com/imosed/signet/data"
) )


type GetQueuesResponse struct { type GetQueuesResponse struct {
Queues []Queue `json:"queues"` Queues []Queue `json:"queues"`
} }


func GetQueues(w http.ResponseWriter, r *http.Request) {
func GetQueues(w http.ResponseWriter, _ *http.Request) {
var resp GetQueuesResponse var resp GetQueuesResponse


Db.Table("queues").Scan(&resp.Queues) Db.Table("queues").Scan(&resp.Queues)


+ 3
- 2
endpoints/register.go View File

@@ -7,12 +7,13 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net/http"
"strings"

"github.com/imosed/signet/auth" "github.com/imosed/signet/auth"
. "github.com/imosed/signet/data" . "github.com/imosed/signet/data"
"github.com/spf13/viper" "github.com/spf13/viper"
"golang.org/x/crypto/argon2" "golang.org/x/crypto/argon2"
"net/http"
"strings"
) )


const ( const (


+ 3
- 2
endpoints/users.go View File

@@ -2,11 +2,12 @@ package endpoints


import ( import (
"encoding/json" "encoding/json"
. "github.com/imosed/signet/data"
"net/http" "net/http"

. "github.com/imosed/signet/data"
) )


func UsersExist(w http.ResponseWriter, r *http.Request) {
func UsersExist(w http.ResponseWriter, _ *http.Request) {
var numUsers int64 var numUsers int64
Db.Table("users").Count(&numUsers) Db.Table("users").Count(&numUsers)




+ 0
- 11
helpers.go View File

@@ -1,11 +0,0 @@
package main

import "github.com/imosed/signet/data"

func SumContributions(contributions []data.Contribution) (sum float64) {
total := 0.0
for _, contribution := range contributions {
total += contribution.Amount
}
return total
}

+ 3
- 2
main.go View File

@@ -2,11 +2,12 @@ package main


import ( import (
"fmt" "fmt"
"net/http"

"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/imosed/signet/data" "github.com/imosed/signet/data"
"github.com/imosed/signet/endpoints" "github.com/imosed/signet/endpoints"
"github.com/spf13/viper" "github.com/spf13/viper"
"net/http"
) )


var err error var err error
@@ -36,7 +37,7 @@ func main() {
router.HandleFunc("/GetQueueMembers", endpoints.GetQueueMembers) router.HandleFunc("/GetQueueMembers", endpoints.GetQueueMembers)
router.HandleFunc("/CreateRewardFund", endpoints.CreateRewardFund) router.HandleFunc("/CreateRewardFund", endpoints.CreateRewardFund)
router.HandleFunc("/CloseRewardFund", endpoints.CloseRewardFund) router.HandleFunc("/CloseRewardFund", endpoints.CloseRewardFund)
//router.HandleFunc("/SubmitFund", endpoints.SubmitFund)
// router.HandleFunc("/SubmitFund", endpoints.SubmitFund)
router.HandleFunc("/GetBalance", endpoints.GetBalance) router.HandleFunc("/GetBalance", endpoints.GetBalance)
router.HandleFunc("/Contribute", endpoints.Contribute) router.HandleFunc("/Contribute", endpoints.Contribute)
router.HandleFunc("/ContributorStream", endpoints.ContributorStream) router.HandleFunc("/ContributorStream", endpoints.ContributorStream)


Loading…
Cancel
Save