Giter Site home page Giter Site logo

Comments (4)

eduard-vasinskyi avatar eduard-vasinskyi commented on June 11, 2024 1

@akumaburn

We have mostly finished changing the HTTP API in the master branch. You can familiarize yourself with the changes by looking at the last commits in the branch.

from activej.

eduard-vasinskyi avatar eduard-vasinskyi commented on June 11, 2024

Hi @akumaburn

Here are some ideas behind HTTP messages design:

  • HTTP message is a hybrid of a builder pattern and an effectively immutable class
  • For the purposes of performance and simplicity, we decided not to make a separate builder class, nevertheless, it is worth working with it as a builder that builds the resulting immutable objects
  • Adding headers, cookies is an add-only operation, we can't mutate those already added, and it's impossible because under the hood we use optimized data structures
  • It also has an ‘ownership’ concept similar to the Rust one, and you can't just make getters in some cases (body streams for example) and the framework manages the ownership of nested objects
  • As for DSL syntax, static factory methods like ok200() don't involve creating a response with "empty" code. and making ok200().withCode(500) is somehow not very nice

However, there seems to be no particular reason to make the code field immutable, since it is not used in high-performance loops, etc. Adding a withCode() method is not necessary, as with… methods should only be used when creating instances and there is a static factory HttpResponse.ofCode(code) for that.

If you don't mind, I will close your PR on this issue and make this change myself, since there are some additional prerequisites that must be met for such a setter, like checking the recycling status of the request. By the way, we are planning extensive changes to HttpRequest/HttpResponse in subsequent versions of ActiveJ, so these API changes will become irrelevant.

from activej.

akumaburn avatar akumaburn commented on June 11, 2024

@eduard-vasinskyi I see. That's fine to close the PR.

May I have some idea of the changes planned for HttpRequest/HttpResponse . I'm currently in the process of evaluating the feasibility of migrating a large amount of payara servlet code over to ActiveJ and it would help not to have to re-write everything when the changes are made.

At the very least if we could have some kind of deprecation plan it would be very helpful.

from activej.

akumaburn avatar akumaburn commented on June 11, 2024

Edit: I think creating an Instance of the Builder and only building at the moment it is used will solve my issue, so this can be closed.

from activej.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.