commit inicial do projeto
This commit is contained in:
42
internal/api/router.go
Normal file
42
internal/api/router.go
Normal file
@ -0,0 +1,42 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gorilla/mux"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func NewRouter(h *Handler) http.Handler {
|
||||
r := mux.NewRouter()
|
||||
|
||||
r.HandleFunc("/health", h.Health).Methods("GET")
|
||||
r.HandleFunc("/startup", h.Startup).Methods("GET")
|
||||
r.HandleFunc("/ready", h.Ready).Methods("GET")
|
||||
|
||||
// ⚡ Transações
|
||||
r.HandleFunc("/transaction", h.SendTransaction).Methods("POST")
|
||||
r.HandleFunc("/transaction/{hash}", h.GetTransactionByHash).Methods("GET")
|
||||
|
||||
// 🔐 Staking
|
||||
r.HandleFunc("/stake", h.StakeHandler).Methods("POST")
|
||||
r.HandleFunc("/unstake", h.UnstakeHandler).Methods("POST")
|
||||
r.HandleFunc("/stake/{address}", h.GetStakeInfo).Methods("GET")
|
||||
|
||||
// 🗳️ DAO
|
||||
r.HandleFunc("/dao/proposals", h.CreateProposal).Methods("POST")
|
||||
r.HandleFunc("/dao/proposals/{id}/vote", h.VoteProposal).Methods("POST")
|
||||
r.HandleFunc("/dao/proposals", h.ListProposals).Methods("GET")
|
||||
r.HandleFunc("/dao/proposals/{id}", h.GetProposal).Methods("GET")
|
||||
|
||||
// 💰 Accounts
|
||||
r.HandleFunc("/accounts/{address}", HandleGetBalance).Methods("GET")
|
||||
r.HandleFunc("/accounts/{address}/txs", HandleGetTransactionsByAddress).Methods("GET")
|
||||
|
||||
// 📦 Blocos
|
||||
r.HandleFunc("/blocks", h.ListBlocks).Methods("GET")
|
||||
r.HandleFunc("/blocks/{height}", h.GetBlockByHeight).Methods("GET")
|
||||
|
||||
// ❤️ Heartbeat
|
||||
r.HandleFunc("/ping", HandlePing).Methods("GET")
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user