WebsocketClientFile returns the file implementing the WebSocket client streaming implementation if any.
(genpkg string, svc *expr.HTTPServiceExpr, services *ServicesData)
| 272 | // WebsocketClientFile returns the file implementing the WebSocket client |
| 273 | // streaming implementation if any. |
| 274 | func 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. |
no test coverage detected