-
Notifications
You must be signed in to change notification settings - Fork 17
/
request.go
60 lines (47 loc) · 1.05 KB
/
request.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
package betwixt
import (
"github.com/zubairhamed/canopus"
)
// Default is a helper/shortcut method which creates a Default LWM2M Request
func Default(coap canopus.CoapRequest, op OperationType) Lwm2mRequest {
return &DefaultRequest{
coap: coap,
op: op,
}
}
type DefaultRequest struct {
coap canopus.CoapRequest
op OperationType
}
func (r *DefaultRequest) GetPath() string {
return r.coap.GetMessage().GetURIPath()
}
func (r *DefaultRequest) GetMessage() *canopus.Message {
return r.coap.GetMessage()
}
func (r *DefaultRequest) GetOperationType() OperationType {
return r.op
}
func (r *DefaultRequest) GetCoapRequest() canopus.CoapRequest {
return r.coap
}
func Nil(op OperationType) Lwm2mRequest {
return &NilRequest{
op: op,
}
}
type NilRequest struct {
op OperationType
}
func (r *NilRequest) GetPath() string {
return ""
}
func (r *NilRequest) GetMessage() *canopus.Message {
return nil
}
func (r *NilRequest) GetOperationType() OperationType {
return r.op
}
func (r *NilRequest) GetCoapRequest() canopus.CoapRequest {
return nil
}