iri icon indicating copy to clipboard operation
iri copied to clipboard

Api command functional routing

Open yovendielmundo opened this issue 7 years ago • 6 comments

  1. Use runtime exceptions and handle it all in the same place Improve readability/maintainability. Ease create proper http responses.
  2. Refactor how to validate and get an uri from strings
  3. Request body errors as bad request responses
  4. Use functional hash mapping for command routing instead of switch cases Improve readability/maintainability/efficiency of the code.

yovendielmundo avatar Dec 06 '17 08:12 yovendielmundo

Thank you @gubatron for the review. I hope something can be use.

yovendielmundo avatar Dec 20 '17 12:12 yovendielmundo

I was considering using jax-rs. However, since your solution may also be satisfactory it may be accepted when we come around to refactor the API.

GalRogozinski avatar Mar 15 '18 13:03 GalRogozinski

I'm coming from https://github.com/iotaledger/iri/pull/743, where the command pattern was cited.

In that PR the Codacy bot is suggesting to lower the complexity of the method process(...) in the API.

In order to have better structure with less complexity, the logic should be something like it was commited in this issue, more precisely https://github.com/iotaledger/iri/pull/392/commits/53c519991f114ca613e3f03a5545d200d842f9cc

brunoamancio avatar May 06 '18 18:05 brunoamancio

Hey @yovendielmundo,

Will you be willing to do an implementation of the API using JAX-RS with RESTEASY? I liked your use of the commander pattern but I think that for the longer term, using JAX-RS will be better.

If you agree, here is a link to a quick tutorial to get started: https://github.com/vdevigere/undertow-cdi-jaxrs/wiki.

GalRogozinski avatar May 13 '18 16:05 GalRogozinski

@GalRogozinski What if we implement the basic functionality he committed in https://github.com/iotaledger/iri/commit/53c519991f114ca613e3f03a5545d200d842f9cc so that the current structure becomes more malleable faster and then go on to using that tool?

brunoamancio avatar May 13 '18 17:05 brunoamancio

That makes good sense actually. Go for it.

I'll keep an eye on this PR.

On Sun, May 13, 2018, 8:13 PM Bruno A. dos Santos [email protected] wrote:

@GalRogozinski https://github.com/GalRogozinski What if we implement the basic functionality he committed in 53c5199 https://github.com/iotaledger/iri/commit/53c519991f114ca613e3f03a5545d200d842f9cc so that the current structure becomes more malleable faster and then go on to using that tool?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iotaledger/iri/pull/392#issuecomment-388641867, or mute the thread https://github.com/notifications/unsubscribe-auth/AHlhl69szdfUYQ1UKJARrnOAw92sHUGCks5tyGnKgaJpZM4Q3j6Q .

GalRogozinski avatar May 13 '18 19:05 GalRogozinski