websocketServerFile returns the file implementing the WebSocket server streaming implementation if any.
(genpkg string, svc *expr.HTTPServiceExpr, services *ServicesData)
| 239 | // websocketServerFile returns the file implementing the WebSocket server |
| 240 | // streaming implementation if any. |
| 241 | func 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. |
no test coverage detected