-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbottle.go
72 lines (61 loc) · 1.77 KB
/
bottle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"github.com/goadesign/goa"
"github.com/goadesign/gorma-cellar/app"
"golang.org/x/net/websocket"
"io"
)
// BottleController implements the bottle resource.
type BottleController struct {
*goa.Controller
}
// NewBottleController creates a bottle controller.
func NewBottleController(service *goa.Service) *BottleController {
return &BottleController{Controller: service.NewController("bottle")}
}
// Create runs the create action.
func (c *BottleController) Create(ctx *app.CreateBottleContext) error {
// TBD: implement
return nil
}
// Delete runs the delete action.
func (c *BottleController) Delete(ctx *app.DeleteBottleContext) error {
// TBD: implement
return nil
}
// List runs the list action.
func (c *BottleController) List(ctx *app.ListBottleContext) error {
// TBD: implement
res := app.BottleCollection{}
return ctx.OK(res)
}
// Rate runs the rate action.
func (c *BottleController) Rate(ctx *app.RateBottleContext) error {
// TBD: implement
return nil
}
// Show runs the show action.
func (c *BottleController) Show(ctx *app.ShowBottleContext) error {
// TBD: implement
res := &app.Bottle{}
return ctx.OK(res)
}
// Update runs the update action.
func (c *BottleController) Update(ctx *app.UpdateBottleContext) error {
// TBD: implement
return nil
}
// Watch runs the watch action.
func (c *BottleController) Watch(ctx *app.WatchBottleContext) error {
c.WatchWSHandler(ctx).ServeHTTP(ctx.ResponseWriter, ctx.Request)
return nil
}
// WatchWSHandler establishes a websocket connection to run the watch action.
func (c *BottleController) WatchWSHandler(ctx *app.WatchBottleContext) websocket.Handler {
return func(ws *websocket.Conn) {
// TBD: implement
ws.Write([]byte("watch bottle"))
// Dummy echo websocket server
io.Copy(ws, ws)
}
}