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

[feat] sse client support method and body configure #988

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from

Conversation

vegetablechicken233
Copy link

@vegetablechicken233 vegetablechicken233 commented Mar 21, 2025

Make HTTP Method configurable and add corresponding test functions.
It should be noted that to ensure backward compatibility, the "method" field does not perform empty validation, but is set to "GET" by default (to align with the old version).
In addition, type of "body" field is temporarily set to "io.Reader" (it seems a bit too early to add support for "any"~

Separated from PR #985

Copy link
Member

@jeevatkm jeevatkm left a comment

Choose a reason for hiding this comment

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

@vegetablechicken233 Thanks for creating a new PR. Just one minor comment on godoc. Once fixed, I will get it merged.

sse.go Outdated
@@ -139,6 +150,14 @@ func (es *EventSource) SetHeader(header, value string) *EventSource {
return es
}

// SetBody method sets body value to the [EventSource] instance
//
// es.SetBody([]byte(`{"test":"put_data"}`),)
Copy link
Member

Choose a reason for hiding this comment

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

@vegetablechicken233 This good example requires a correction based on method input type. Also, it has a syntax issue: , is present near the closing curve bracket.

es.SetBody(strings.NewReader(`{"test":"put_data"}`))

Choose a reason for hiding this comment

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

@jeevatkm already fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants