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

Function websocketServerFile

http/codegen/websocket.go:241–270  ·  view source on GitHub ↗

websocketServerFile returns the file implementing the WebSocket server streaming implementation if any.

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

Source from the content-addressed store, hash-verified

239// websocketServerFile returns the file implementing the WebSocket server
240// streaming implementation if any.
241func websocketServerFile(genpkg string, svc *expr.HTTPServiceExpr, services *ServicesData) *codegen.File {
242 data := services.Get(svc.Name())
243 if !HasWebSocket(data) {
244 return nil
245 }
246 svcName := data.Service.PathName
247 title := fmt.Sprintf("%s WebSocket server streaming", svc.Name())
248 imports := []*codegen.ImportSpec{
249 {Path: "context"},
250 {Path: "io"},
251 {Path: "net/http"},
252 {Path: "sync"},
253 {Path: "time"},
254 {Path: "github.com/gorilla/websocket"},
255 codegen.GoaImport(""),
256 codegen.GoaNamedImport("http", "goahttp"),
257 {Path: genpkg + "/" + svcName, Name: data.Service.PkgName},
258 }
259 structSections := serverStructWSSections(data)
260 wsSections := serverWSSections(data)
261 sections := make([]*codegen.SectionTemplate, 0, 1+len(structSections)+len(wsSections))
262 sections = append(sections, codegen.Header(title, "server", imports))
263 sections = append(sections, structSections...)
264 sections = append(sections, wsSections...)
265
266 return &codegen.File{
267 Path: filepath.Join(codegen.Gendir, "http", svcName, "server", "websocket.go"),
268 SectionTemplates: sections,
269 }
270}
271
272// WebsocketClientFile returns the file implementing the WebSocket client
273// streaming implementation if any.

Callers 1

ServerFilesFunction · 0.70

Calls 8

GoaImportFunction · 0.92
GoaNamedImportFunction · 0.92
HeaderFunction · 0.92
HasWebSocketFunction · 0.85
serverStructWSSectionsFunction · 0.85
serverWSSectionsFunction · 0.85
NameMethod · 0.65
GetMethod · 0.45

Tested by

no test coverage detected