Skip to content

Commit 12c57bb

Browse files
rwjblue-gleantendant
authored andcommitted
refactor(server/sse): rename WithBasePath to WithStaticBasePath for clarity (mark3labs#238)
The new name makes its relationship to `WithDynamicBasePath` clearer. The implementation preserves the original functionality with a build time warning (in go 1.21+).
1 parent 48c8bb6 commit 12c57bb

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

server/sse.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,22 @@ func WithBaseURL(baseURL string) SSEOption {
135135
}
136136
}
137137

138-
// WithBasePath adds a new option for setting a static base path
139-
func WithBasePath(basePath string) SSEOption {
138+
// WithStaticBasePath adds a new option for setting a static base path
139+
func WithStaticBasePath(basePath string) SSEOption {
140140
return func(s *SSEServer) {
141141
s.basePath = normalizeURLPath(basePath)
142142
}
143143
}
144144

145+
// WithBasePath adds a new option for setting a static base path.
146+
//
147+
// Deprecated: Use WithStaticBasePath instead. This will be removed in a future version.
148+
//
149+
//go:deprecated
150+
func WithBasePath(basePath string) SSEOption {
151+
return WithStaticBasePath(basePath)
152+
}
153+
145154
// WithDynamicBasePath accepts a function for generating the base path. This is
146155
// useful for cases where the base path is not known at the time of SSE server
147156
// creation, such as when using a reverse proxy or when the server is mounted

server/sse_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestSSEServer(t *testing.T) {
2424
mcpServer := NewMCPServer("test", "1.0.0")
2525
sseServer := NewSSEServer(mcpServer,
2626
WithBaseURL("http://localhost:8080"),
27-
WithBasePath("/mcp"),
27+
WithStaticBasePath("/mcp"),
2828
)
2929

3030
if sseServer == nil {
@@ -499,7 +499,7 @@ func TestSSEServer(t *testing.T) {
499499

500500
t.Run("works as http.Handler with custom basePath", func(t *testing.T) {
501501
mcpServer := NewMCPServer("test", "1.0.0")
502-
sseServer := NewSSEServer(mcpServer, WithBasePath("/mcp"))
502+
sseServer := NewSSEServer(mcpServer, WithStaticBasePath("/mcp"))
503503

504504
ts := httptest.NewServer(sseServer)
505505
defer ts.Close()
@@ -717,7 +717,7 @@ func TestSSEServer(t *testing.T) {
717717
useFullURLForMessageEndpoint := false
718718
srv := &http.Server{}
719719
rands := []SSEOption{
720-
WithBasePath(basePath),
720+
WithStaticBasePath(basePath),
721721
WithBaseURL(baseURL),
722722
WithMessageEndpoint(messageEndpoint),
723723
WithUseFullURLForMessageEndpoint(useFullURLForMessageEndpoint),

0 commit comments

Comments
 (0)