blob: 88a00112d1b75e9f4653b9a0a3fbc841a8b89a09 (
plain) (
blame)
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
|
// Package api contains type definitions for the gob API.
package api
import "encoding/gob"
type ErrorCode int
//go:generate go tool stringer -type=ErrorCode
const (
Ok ErrorCode = iota
Unauthenticated // missing credentials
PermissionDenied // invalid credentials, or login required
BadRequest // incorrect request format (try gob)
InvalidArgument // one or more arguments was invalid
NotFound // requested resource was not found
Internal // server encountered an unexpected error
)
func (c ErrorCode) Error() string {
return c.String()
}
type Response struct {
Status ErrorCode
Err string
Ok any
}
type LoginResponse struct {
Token string
}
type ListNotesRequest struct{}
type ListNotesResponse struct {
Notes []string
}
type CreateNoteRequest struct {
ContinuationToken []byte
Chunk []byte
More bool
}
type CreateNoteResponse struct {
Name string
ContinuationToken []byte
}
type ReadNoteRequest struct {
Note string
}
type ReadNoteResponseStream struct {
Chunk []byte
}
type DeleteNoteRequest struct{}
type DeleteNoteResponse struct{}
func init() {
gob.Register(&LoginResponse{})
gob.Register(&ListNotesResponse{})
gob.Register(&CreateNoteResponse{})
gob.Register(&ReadNoteResponseStream{})
gob.Register(&DeleteNoteResponse{})
}
|