@@ -5,11 +5,13 @@ func (h *Harness) setupHTTP() {
55
66 // Create HTTP handler
77 mux := goahttp.NewMuxer ()
8+ {{- if .HasStreams }}
89 // Create WebSocket upgrader for streaming endpoints
910 upgrader := &websocket.Upgrader {
1011 CheckOrigin: func(r *http.Request ) bool { return true },
1112 }
12- server := httpsvr.New (endpoints, mux, goahttp.RequestDecoder , goahttp.ResponseEncoder , nil , nil , upgrader, nil )
13+ {{- end }}
14+ server := httpsvr.New (endpoints, mux, goahttp.RequestDecoder , goahttp.ResponseEncoder , nil , nil {{ if .HasStreams }}, upgrader, nil {{ end }})
1315 httpsvr.Mount (mux, server)
1416
1517 // Create test server
@@ -31,46 +33,50 @@ func (h *Harness) HTTPClient() *http.Client {
3133
3234{{ printf " getHTTPClientImpl returns the underlying HTTP client implementation." | comment }}
3335func (h *Harness) getHTTPClientImpl() *httpcli.Client {
34- if h.httpSvr == nil || h.httpCli == nil {
35- h.t.Fatal (" HTTP transport not configured" )
36- }
37- u, err := url.Parse (h.httpSvr.URL )
38- if err != nil {
39- h.t.Fatalf (" invalid test server URL: %v " , err)
40- }
41- scheme := u.Scheme
42- host := u.Host
43- // Create WebSocket dialer for streaming endpoints
44- wsDialer := &websocket.Dialer {
45- Proxy: http.ProxyFromEnvironment ,
46- }
47-
48- return httpcli.NewClient (
49- scheme,
50- host,
51- h.httpCli ,
52- goahttp.RequestEncoder ,
53- goahttp.ResponseDecoder ,
54- false,
55- wsDialer,
56- nil ,
57- )
36+ if h.httpSvr == nil || h.httpCli == nil {
37+ h.t.Fatal (" HTTP transport not configured" )
38+ }
39+ u, err := url.Parse (h.httpSvr.URL )
40+ if err != nil {
41+ h.t.Fatalf (" invalid test server URL: %v " , err)
42+ }
43+ scheme := u.Scheme
44+ host := u.Host
45+ {{- if .HasStreams }}
46+ // Create WebSocket dialer for streaming endpoints
47+ wsDialer := &websocket.Dialer {
48+ Proxy: http.ProxyFromEnvironment ,
49+ }
50+ {{- end }}
51+
52+ return httpcli.NewClient (
53+ scheme,
54+ host,
55+ h.httpCli ,
56+ goahttp.RequestEncoder ,
57+ goahttp.ResponseDecoder ,
58+ false,
59+ {{- if .HasStreams }}
60+ wsDialer,
61+ nil ,
62+ {{- end }}
63+ )
5864}
5965
6066{{ printf " HTTPClientEndpoints creates HTTP client endpoints for the service." | comment }}
6167func (h *Harness) HTTPClientEndpoints() *{{ .PkgName }}.Endpoints {
62- c := h.getHTTPClientImpl ()
63- return &{{ .PkgName }}.Endpoints {
64- {{- range .Methods }}
65- {{- $method := . }}
66- {{- range .Targets }}
67- {{- if or .IsHTTPPlain .IsHTTPServerSent .IsHTTPWebSocket }}
68- {{ $method .VarName }}: c. {{ $method .VarName }}(),
69- {{- break }}
70- {{- end }}
71- {{- end }}
72- {{- end }}
73- }
68+ c := h.getHTTPClientImpl ()
69+ return &{{ .PkgName }}.Endpoints {
70+ {{- range .Methods }}
71+ {{- $method := . }}
72+ {{- range .Targets }}
73+ {{- if or .IsHTTPPlain .IsHTTPServerSent .IsHTTPWebSocket }}
74+ {{ $method .VarName }}: c. {{ $method .VarName }}(),
75+ {{- break }}
76+ {{- end }}
77+ {{- end }}
78+ {{- end }}
79+ }
7480}
7581
7682{{ printf " HTTPURL returns the base URL of the test HTTP server." | comment }}
@@ -108,6 +114,7 @@ func (h *Harness) HTTPRequest(method, path string, body any) *http.Request {
108114 return req
109115}
110116
117+ {{- if .HasStreams }}
111118{{ printf " HTTPWSURL builds a websocket URL from the base HTTP URL and path." | comment }}
112119func (h *Harness) HTTPWSURL(path string) string {
113120 base := h.HTTPURL ()
@@ -123,6 +130,7 @@ func (h *Harness) HTTPWSURL(path string) string {
123130 u.Path = path
124131 return u.String ()
125132}
133+ {{- end }}
126134
127135{{ printf " HTTPDo performs an HTTP request and returns the response." | comment }}
128136func (h *Harness) HTTPDo(req *http.Request ) *http.Response {
0 commit comments