Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a http snoop server sample #2883

Merged
merged 13 commits into from
Sep 1, 2023

Conversation

longkunbetter
Copy link
Contributor

Add a 'http snoop server' sample which receives any request and tells the client the details of the request in a formatted string #{761}

This is a sample http server that corresponds to HttpSnoopServer in examples of project netty.

Please notice that the http snoop server is not the same as the http echo server.
It will return the details of the request, not only the request body.
So I think it is a good example for people who want to learn how to use reactor-netty to build a http server and have a full control of the request and response.

I have tested it and it works well.

I'm unfamilar with such PR operation, if there is any problem please tell me.

@pivotal-cla
Copy link

@longkunbetter Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@longkunbetter Thank you for signing the Contributor License Agreement!

@longkunbetter
Copy link
Contributor Author

#761

@longkunbetter longkunbetter reopened this Aug 30, 2023
@longkunbetter longkunbetter marked this pull request as draft August 30, 2023 03:02
@longkunbetter longkunbetter marked this pull request as ready for review August 30, 2023 03:03
@longkunbetter longkunbetter marked this pull request as draft August 30, 2023 03:03
@longkunbetter longkunbetter marked this pull request as ready for review August 30, 2023 03:15
…and tells the client the details of the request in a formatted string #{761}
@violetagg
Copy link
Member

@longkunbetter Thanks for the PR.

Can you use the same pattern as below link (for system properties etc.)

https://github.com/reactor/reactor-netty/tree/main/reactor-netty-examples/src/main/java/reactor/netty/examples/http/helloworld

@violetagg violetagg added the type/documentation A documentation update label Aug 30, 2023
@violetagg violetagg added this to the 1.1.x Backlog milestone Aug 30, 2023
@longkunbetter
Copy link
Contributor Author

@violetagg Thanks for your feedback.
I'll adjust my code soon.

@longkunbetter
Copy link
Contributor Author

@violetagg
I have adjusted the code style to be consistent with the rest of the project.
In the original version, I want to let my code be a bit more object-oriented, but it seems that it is too tedious to do so for a simple code.

@violetagg violetagg changed the title add a 'http snoop server' sample Add a http snoop server sample Sep 1, 2023
longkunbetter and others added 5 commits September 1, 2023 16:14
…tp/snoop/HttpSnoopClient.java

Co-authored-by: Violeta Georgieva <milesg78@gmail.com>
…tp/snoop/HttpSnoopClient.java

Co-authored-by: Violeta Georgieva <milesg78@gmail.com>
…tp/snoop/HttpSnoopClient.java

Co-authored-by: Violeta Georgieva <milesg78@gmail.com>
…tp/snoop/HttpSnoopServer.java

Co-authored-by: Violeta Georgieva <milesg78@gmail.com>
…tp/snoop/HttpSnoopServer.java

Co-authored-by: Violeta Georgieva <milesg78@gmail.com>
@violetagg violetagg modified the milestones: 1.1.x Backlog, 1.1.11 Sep 1, 2023
@violetagg violetagg requested a review from a team September 1, 2023 08:18
@violetagg
Copy link
Member

@longkunbetter Can you fix the import

/home/runner/work/reactor-netty/reactor-netty/reactor-netty-examples/src/main/java/reactor/netty/examples/http/snoop/HttpSnoopClient.java:64: error: cannot find symbol

				      .send(ByteBufMono.fromString(Mono.just("{\"foo\": 1,\"bar\": 2}")))

Kun.Long and others added 3 commits September 1, 2023 17:15
…tp/snoop/HttpSnoopClient.java

Co-authored-by: Pierre De Rop <pierre.derop@gmail.com>
…tp/snoop/HttpSnoopServer.java

Co-authored-by: Pierre De Rop <pierre.derop@gmail.com>
@longkunbetter
Copy link
Contributor Author

@longkunbetter Can you fix the import

/home/runner/work/reactor-netty/reactor-netty/reactor-netty-examples/src/main/java/reactor/netty/examples/http/snoop/HttpSnoopClient.java:64: error: cannot find symbol

				      .send(ByteBufMono.fromString(Mono.just("{\"foo\": 1,\"bar\": 2}")))

I have fixed it. Should I squash my commits?

@violetagg
Copy link
Member

Should I squash my commits?

No need I can squash them

Copy link
Member

@violetagg violetagg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests failure on CI with Mac OS is not relevant to this PR

@violetagg violetagg merged commit 37fcf0a into reactor:main Sep 1, 2023
7 of 9 checks passed
violetagg added a commit that referenced this pull request Sep 1, 2023
@violetagg
Copy link
Member

@longkunbetter Thanks again for the PR!

@longkunbetter
Copy link
Contributor Author

@longkunbetter Thanks again for the PR!

No thanks, I'm glad to contribute to this project.
Perhaps I will contribute more in the future, before that I need to learn more about the code style of this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/documentation A documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants