File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ func NewHTTPMcpHandler(cfg *HTTPServerConfig,
7777}
7878
7979// RegisterRoutes registers the routes for the MCP server
80+ // URL-based values take precedence over header-based values
8081func (h * HTTPMcpHandler ) RegisterRoutes (r chi.Router ) {
8182 r .Use (middleware .WithRequestConfig )
8283
Original file line number Diff line number Diff line change 1+ package headers
2+
3+ import (
4+ "testing"
5+
6+ "github.com/stretchr/testify/assert"
7+ )
8+
9+ func TestParseCommaSeparated (t * testing.T ) {
10+ tests := []struct {
11+ name string
12+ input string
13+ expected []string
14+ }{
15+ {
16+ name : "empty string" ,
17+ input : "" ,
18+ expected : []string {},
19+ },
20+ {
21+ name : "single value" ,
22+ input : "foo" ,
23+ expected : []string {"foo" },
24+ },
25+ {
26+ name : "multiple values" ,
27+ input : "foo,bar,baz" ,
28+ expected : []string {"foo" , "bar" , "baz" },
29+ },
30+ {
31+ name : "whitespace trimmed" ,
32+ input : " foo , bar , baz " ,
33+ expected : []string {"foo" , "bar" , "baz" },
34+ },
35+ {
36+ name : "empty values filtered" ,
37+ input : "foo,,bar," ,
38+ expected : []string {"foo" , "bar" },
39+ },
40+ {
41+ name : "only commas" ,
42+ input : ",,," ,
43+ expected : []string {},
44+ },
45+ {
46+ name : "whitespace only values filtered" ,
47+ input : "foo, ,bar" ,
48+ expected : []string {"foo" , "bar" },
49+ },
50+ }
51+
52+ for _ , tt := range tests {
53+ t .Run (tt .name , func (t * testing.T ) {
54+ result := ParseCommaSeparated (tt .input )
55+ assert .Equal (t , tt .expected , result )
56+ })
57+ }
58+ }
You can’t perform that action at this time.
0 commit comments