-
Notifications
You must be signed in to change notification settings - Fork 29
/
server.go
51 lines (42 loc) · 1011 Bytes
/
server.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
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package meeting
import (
"gopkg.in/errgo.v1"
"gopkg.in/httprequest.v1"
)
type handler struct {
place *Place
}
type waitRequest struct {
httprequest.Route `httprequest:"GET /:Id"`
Id string `httprequest:",path"`
}
type waitData struct {
Data0 []byte
Data1 []byte
}
func (h *handler) Wait(p httprequest.Params, req *waitRequest) (*waitData, error) {
data0, data1, err := h.place.localWait(p.Context, req.Id)
if err != nil {
return nil, errgo.Mask(err)
}
return &waitData{
Data0: data0,
Data1: data1,
}, nil
}
type doneData struct {
Data1 []byte
}
type doneRequest struct {
httprequest.Route `httprequest:"PUT /:Id"`
Id string `httprequest:",path"`
Body doneData `httprequest:",body"`
}
func (h *handler) Done(req *doneRequest) error {
if err := h.place.localDone(req.Id, req.Body.Data1); err != nil {
return errgo.Mask(err)
}
return nil
}