micw/server/api/http/transaction.go
2024-11-13 22:10:13 +01:00

54 lines
1.1 KiB
Go

package http
import (
"context"
"encoding/json"
logicErr "mic-wallet/server/logic/err"
"net/http"
)
type NewTransactionReqBody struct {
}
func NewTransaction(w http.ResponseWriter, r *http.Request) *logicErr.Err {
req := &NewTransactionReqBody{}
if err := json.NewDecoder(r.Body).Decode(req); err != nil {
}
if err := r.Body.Close(); err != nil {
}
return nil
}
func GetTransaction(w http.ResponseWriter, r *http.Request) *logicErr.Err {
return nil
}
func GetTransactions(w http.ResponseWriter, r *http.Request) *logicErr.Err {
txHash := r.URL.Query().Get("tx_sh")
if txHash != "" {
return nil
}
pubKey := r.URL.Query().Get("pub_key")
if pubKey != "" {
return nil
}
return nil
}
func MountTransactionRoutes(ctx context.Context, mux *http.ServeMux, thisRoute string) {
thisRoute += "/transaction"
mux.HandleFunc(thisRoute, func(w http.ResponseWriter, r *http.Request) {
var err *logicErr.Err
switch r.Method {
case http.MethodGet:
err = GetTransactions(w, r)
case http.MethodPost:
err = NewTransaction(w, r)
}
logicErr.HandleHttp(ctx, w, r, err)
})
}