Skip to content

Commit

Permalink
Merge pull request #10 from MaximeZmt/Work-Mzmt-EditProxy
Browse files Browse the repository at this point in the history
feat: added new interface to the proxy (part 1)
  • Loading branch information
MaximeZmt authored Jun 20, 2024
2 parents d2080fd + cdda328 commit 8e9babf
Show file tree
Hide file tree
Showing 6 changed files with 474 additions and 100 deletions.
19 changes: 15 additions & 4 deletions contracts/evoting/controller/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ const (
contentType = "application/json"
formPath = "/evoting/forms"
// FormPathSlash is the path to the form with a trailing slash
FormPathSlash = formPath + "/"
formIDPath = FormPathSlash + "{formID}"
transactionSlash = "/evoting/transactions/"
FormPathSlash = formPath + "/"
formIDPath = FormPathSlash + "{formID}"
transactionSlash = "/evoting/transactions/"

evotingPathSlash = "/evoting/"

transactionPath = transactionSlash + "{token}"
unexpectedStatus = "unexpected status: %s, body: %s"
failRetrieveDecryption = "failed to retrieve decryption key: %v"
Expand Down Expand Up @@ -169,12 +172,19 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
return xerrors.Errorf("failed to unmarshal proxy key: %v", err)
}

transactionManager := txnmanager.NewTransactionManager(mngr, p, sjson.NewContext(), proxykey, blocks, signer)
transactionManager := txnmanager.NewTransactionManager(mngr, p, sjson.NewContext(), proxykey, blocks, signer, validation)

ep := eproxy.NewForm(ordering, p, sjson.NewContext(), formFac, proxykey, transactionManager)

router := mux.NewRouter()

router.HandleFunc(evotingPathSlash+"addadmin", ep.AddAdmin).Methods("POST")
router.HandleFunc(evotingPathSlash+"removeadmin", ep.RemoveAdmin).Methods("POST")
router.HandleFunc(evotingPathSlash+"adminlist", ep.AdminList).Methods("GET")
router.HandleFunc(formIDPath+"/addowner", ep.AddOwnerToForm).Methods("POST")
router.HandleFunc(formIDPath+"/removeowner", ep.RemoveOwnerToForm).Methods("POST")
router.HandleFunc(formIDPath+"/addvoter", ep.AddVoterToForm).Methods("POST")
router.HandleFunc(formIDPath+"/removevoter", ep.RemoveVoterToForm).Methods("POST")
router.HandleFunc(formPath, ep.NewForm).Methods("POST")
router.HandleFunc(formPath, ep.Forms).Methods("GET")
router.HandleFunc(formPath, eproxy.AllowCORS).Methods("OPTIONS")
Expand All @@ -188,6 +198,7 @@ func (a *RegisterAction) Execute(ctx node.Context) error {
router.NotFoundHandler = http.HandlerFunc(eproxy.NotFoundHandler)
router.MethodNotAllowedHandler = http.HandlerFunc(eproxy.NotAllowedHandler)

proxy.RegisterHandler(evotingPathSlash, router.ServeHTTP)
proxy.RegisterHandler(formPath, router.ServeHTTP)
proxy.RegisterHandler(FormPathSlash, router.ServeHTTP)
proxy.RegisterHandler(transactionSlash, router.ServeHTTP)
Expand Down
Loading

0 comments on commit 8e9babf

Please sign in to comment.