MCPcopy Create free account
hub / github.com/goadesign/goa / WebsocketClientFile

Function WebsocketClientFile

http/codegen/websocket.go:274–304  ·  view source on GitHub ↗

WebsocketClientFile returns the file implementing the WebSocket client streaming implementation if any.

(genpkg string, svc *expr.HTTPServiceExpr, services *ServicesData)

Source from the content-addressed store, hash-verified

272// WebsocketClientFile returns the file implementing the WebSocket client
273// streaming implementation if any.
274func WebsocketClientFile(genpkg string, svc *expr.HTTPServiceExpr, services *ServicesData) *codegen.File {
275 data := services.Get(svc.Name())
276 if !HasWebSocket(data) {
277 return nil
278 }
279 svcName := data.Service.PathName
280 title := fmt.Sprintf("%s WebSocket client streaming", svc.Name())
281 imports := []*codegen.ImportSpec{
282 {Path: "context"},
283 {Path: "io"},
284 {Path: "net/http"},
285 {Path: "sync"},
286 {Path: "time"},
287 {Path: "github.com/gorilla/websocket"},
288 codegen.GoaImport(""),
289 codegen.GoaNamedImport("http", "goahttp"),
290 {Path: genpkg + "/" + svcName + "/" + "views", Name: data.Service.ViewsPkg},
291 {Path: genpkg + "/" + svcName, Name: data.Service.PkgName},
292 }
293 structSections := clientStructWSSections(data)
294 wsSections := clientWSSections(data)
295 sections := make([]*codegen.SectionTemplate, 0, 1+len(structSections)+len(wsSections))
296 sections = append(sections, codegen.Header(title, "client", imports))
297 sections = append(sections, structSections...)
298 sections = append(sections, wsSections...)
299
300 return &codegen.File{
301 Path: filepath.Join(codegen.Gendir, "http", svcName, "client", "websocket.go"),
302 SectionTemplates: sections,
303 }
304}
305
306// serverStructWSSections return section templates that generate WebSocket
307// related struct type definitions for the server.

Callers 1

ClientFilesFunction · 0.85

Calls 8

GoaImportFunction · 0.92
GoaNamedImportFunction · 0.92
HeaderFunction · 0.92
HasWebSocketFunction · 0.85
clientStructWSSectionsFunction · 0.85
clientWSSectionsFunction · 0.85
NameMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected