Comments (4)
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.
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.
@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.
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)
- Websocket Accept/WriteFrame/WriteMessage not processing more than 2 writes HOT 9
- Suggestion - Nightly Snapshots? HOT 1
- Serializer sometimes decodes a wrong class for RPC request HOT 7
- Any sample to declare local varible? HOT 2
- Happen error while uploading file HOT 2
- Release plan for v5.5 and v6 HOT 3
- Add Query Parameters? HOT 6
- RPCClient lock port on local HOT 1
- Version 6 does not support ipv6, version 5.5 supported ipv6 HOT 2
- Make classes Public to facilitate mocking. HOT 1
- RpcClient receive unexpected EOS HOT 2
- RpcClient cannot setup connection
- RpcServer serializer is wrong HOT 4
- Happen error with Serializer in native app HOT 2
- sorry a local problem
- How to hook the end of the HttpResponse so I can clean up some buffers? HOT 4
- Unknown characters when read messages from the websocket HOT 1
- Is it possible to Run a MultiThread Rpc Server? HOT 2
- HttpRequest with custom Host header HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activej.