mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-18 05:35:10 +00:00
add Posts.Index
This commit is contained in:
@@ -183,6 +183,40 @@ func (p *Posts) diffTags(ctx context.Context, parentID string, oldTagNames, newT
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Posts) Index(ctx context.Context, req *proto.IndexRequest, rsp *proto.IndexResponse) error {
|
||||||
|
// create a simple descending order query
|
||||||
|
q := model.QueryEquals("created", nil)
|
||||||
|
q.Order.Type = model.OrderTypeDesc
|
||||||
|
|
||||||
|
var posts []*proto.Post
|
||||||
|
|
||||||
|
// read all the records
|
||||||
|
if err := p.db.Read(q, &posts); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// model does not deal with limits yet
|
||||||
|
limit := int(req.Limit)
|
||||||
|
|
||||||
|
// TODO: implement offset
|
||||||
|
if limit == 0 {
|
||||||
|
limit = 20
|
||||||
|
}
|
||||||
|
// set the limit to length of posts
|
||||||
|
if v := len(posts); v < limit {
|
||||||
|
limit = v
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate and add
|
||||||
|
for i := 0; i <= limit; i++ {
|
||||||
|
// strip the content
|
||||||
|
posts[i].Content = ""
|
||||||
|
rsp.Posts = append(rsp.Posts, posts[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Posts) Query(ctx context.Context, req *proto.QueryRequest, rsp *proto.QueryResponse) error {
|
func (p *Posts) Query(ctx context.Context, req *proto.QueryRequest, rsp *proto.QueryResponse) error {
|
||||||
var q model.Query
|
var q model.Query
|
||||||
if len(req.Slug) > 0 {
|
if len(req.Slug) > 0 {
|
||||||
|
|||||||
@@ -131,6 +131,92 @@ func (m *Post) GetImage() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type IndexRequest struct {
|
||||||
|
Limit int64 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"`
|
||||||
|
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IndexRequest) Reset() { *m = IndexRequest{} }
|
||||||
|
func (m *IndexRequest) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*IndexRequest) ProtoMessage() {}
|
||||||
|
func (*IndexRequest) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_e93dc7d934d9dc10, []int{1}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IndexRequest) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_IndexRequest.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *IndexRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_IndexRequest.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *IndexRequest) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_IndexRequest.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *IndexRequest) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_IndexRequest.Size(m)
|
||||||
|
}
|
||||||
|
func (m *IndexRequest) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_IndexRequest.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_IndexRequest proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *IndexRequest) GetLimit() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Limit
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IndexRequest) GetOffset() int64 {
|
||||||
|
if m != nil {
|
||||||
|
return m.Offset
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type IndexResponse struct {
|
||||||
|
Posts []*Post `protobuf:"bytes,1,rep,name=posts,proto3" json:"posts,omitempty"`
|
||||||
|
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||||
|
XXX_unrecognized []byte `json:"-"`
|
||||||
|
XXX_sizecache int32 `json:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IndexResponse) Reset() { *m = IndexResponse{} }
|
||||||
|
func (m *IndexResponse) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*IndexResponse) ProtoMessage() {}
|
||||||
|
func (*IndexResponse) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_e93dc7d934d9dc10, []int{2}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *IndexResponse) XXX_Unmarshal(b []byte) error {
|
||||||
|
return xxx_messageInfo_IndexResponse.Unmarshal(m, b)
|
||||||
|
}
|
||||||
|
func (m *IndexResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
return xxx_messageInfo_IndexResponse.Marshal(b, m, deterministic)
|
||||||
|
}
|
||||||
|
func (m *IndexResponse) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_IndexResponse.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *IndexResponse) XXX_Size() int {
|
||||||
|
return xxx_messageInfo_IndexResponse.Size(m)
|
||||||
|
}
|
||||||
|
func (m *IndexResponse) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_IndexResponse.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_IndexResponse proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *IndexResponse) GetPosts() []*Post {
|
||||||
|
if m != nil {
|
||||||
|
return m.Posts
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Query posts. Acts as a listing when no id or slug provided.
|
// Query posts. Acts as a listing when no id or slug provided.
|
||||||
// Gets a single post by id or slug if any of them provided.
|
// Gets a single post by id or slug if any of them provided.
|
||||||
type QueryRequest struct {
|
type QueryRequest struct {
|
||||||
@@ -148,7 +234,7 @@ func (m *QueryRequest) Reset() { *m = QueryRequest{} }
|
|||||||
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
|
func (m *QueryRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*QueryRequest) ProtoMessage() {}
|
func (*QueryRequest) ProtoMessage() {}
|
||||||
func (*QueryRequest) Descriptor() ([]byte, []int) {
|
func (*QueryRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{1}
|
return fileDescriptor_e93dc7d934d9dc10, []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
|
func (m *QueryRequest) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -215,7 +301,7 @@ func (m *QueryResponse) Reset() { *m = QueryResponse{} }
|
|||||||
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
|
func (m *QueryResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*QueryResponse) ProtoMessage() {}
|
func (*QueryResponse) ProtoMessage() {}
|
||||||
func (*QueryResponse) Descriptor() ([]byte, []int) {
|
func (*QueryResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{2}
|
return fileDescriptor_e93dc7d934d9dc10, []int{4}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
|
func (m *QueryResponse) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -263,7 +349,7 @@ func (m *SaveRequest) Reset() { *m = SaveRequest{} }
|
|||||||
func (m *SaveRequest) String() string { return proto.CompactTextString(m) }
|
func (m *SaveRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SaveRequest) ProtoMessage() {}
|
func (*SaveRequest) ProtoMessage() {}
|
||||||
func (*SaveRequest) Descriptor() ([]byte, []int) {
|
func (*SaveRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{3}
|
return fileDescriptor_e93dc7d934d9dc10, []int{5}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SaveRequest) XXX_Unmarshal(b []byte) error {
|
func (m *SaveRequest) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -351,7 +437,7 @@ func (m *SaveResponse) Reset() { *m = SaveResponse{} }
|
|||||||
func (m *SaveResponse) String() string { return proto.CompactTextString(m) }
|
func (m *SaveResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*SaveResponse) ProtoMessage() {}
|
func (*SaveResponse) ProtoMessage() {}
|
||||||
func (*SaveResponse) Descriptor() ([]byte, []int) {
|
func (*SaveResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{4}
|
return fileDescriptor_e93dc7d934d9dc10, []int{6}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *SaveResponse) XXX_Unmarshal(b []byte) error {
|
func (m *SaveResponse) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -390,7 +476,7 @@ func (m *DeleteRequest) Reset() { *m = DeleteRequest{} }
|
|||||||
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
func (m *DeleteRequest) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DeleteRequest) ProtoMessage() {}
|
func (*DeleteRequest) ProtoMessage() {}
|
||||||
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
func (*DeleteRequest) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{5}
|
return fileDescriptor_e93dc7d934d9dc10, []int{7}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
func (m *DeleteRequest) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -428,7 +514,7 @@ func (m *DeleteResponse) Reset() { *m = DeleteResponse{} }
|
|||||||
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
func (m *DeleteResponse) String() string { return proto.CompactTextString(m) }
|
||||||
func (*DeleteResponse) ProtoMessage() {}
|
func (*DeleteResponse) ProtoMessage() {}
|
||||||
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
func (*DeleteResponse) Descriptor() ([]byte, []int) {
|
||||||
return fileDescriptor_e93dc7d934d9dc10, []int{6}
|
return fileDescriptor_e93dc7d934d9dc10, []int{8}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
func (m *DeleteResponse) XXX_Unmarshal(b []byte) error {
|
||||||
@@ -452,6 +538,8 @@ var xxx_messageInfo_DeleteResponse proto.InternalMessageInfo
|
|||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*Post)(nil), "posts.Post")
|
proto.RegisterType((*Post)(nil), "posts.Post")
|
||||||
proto.RegisterMapType((map[string]string)(nil), "posts.Post.MetadataEntry")
|
proto.RegisterMapType((map[string]string)(nil), "posts.Post.MetadataEntry")
|
||||||
|
proto.RegisterType((*IndexRequest)(nil), "posts.IndexRequest")
|
||||||
|
proto.RegisterType((*IndexResponse)(nil), "posts.IndexResponse")
|
||||||
proto.RegisterType((*QueryRequest)(nil), "posts.QueryRequest")
|
proto.RegisterType((*QueryRequest)(nil), "posts.QueryRequest")
|
||||||
proto.RegisterType((*QueryResponse)(nil), "posts.QueryResponse")
|
proto.RegisterType((*QueryResponse)(nil), "posts.QueryResponse")
|
||||||
proto.RegisterType((*SaveRequest)(nil), "posts.SaveRequest")
|
proto.RegisterType((*SaveRequest)(nil), "posts.SaveRequest")
|
||||||
@@ -464,34 +552,36 @@ func init() {
|
|||||||
func init() { proto.RegisterFile("proto/posts.proto", fileDescriptor_e93dc7d934d9dc10) }
|
func init() { proto.RegisterFile("proto/posts.proto", fileDescriptor_e93dc7d934d9dc10) }
|
||||||
|
|
||||||
var fileDescriptor_e93dc7d934d9dc10 = []byte{
|
var fileDescriptor_e93dc7d934d9dc10 = []byte{
|
||||||
// 452 bytes of a gzipped FileDescriptorProto
|
// 496 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcb, 0x8e, 0xd3, 0x40,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4b, 0x8e, 0xd3, 0x40,
|
||||||
0x10, 0xc4, 0x76, 0xec, 0x24, 0x9d, 0xcd, 0x2a, 0x74, 0x16, 0x34, 0x44, 0x08, 0x8c, 0x4f, 0x39,
|
0x10, 0x1d, 0x7f, 0x93, 0x54, 0x92, 0x51, 0xe8, 0x0c, 0xa8, 0xb1, 0x10, 0x18, 0xaf, 0xb2, 0x0a,
|
||||||
0x05, 0x11, 0x40, 0x20, 0xe0, 0x08, 0x47, 0x24, 0x30, 0x5f, 0x30, 0xe0, 0xde, 0x60, 0x61, 0xc7,
|
0x22, 0x80, 0x40, 0x30, 0x4b, 0x58, 0xb0, 0x40, 0x02, 0x73, 0x82, 0x06, 0xf7, 0x04, 0x0b, 0xff,
|
||||||
0xc6, 0xd3, 0x5e, 0x29, 0xff, 0xc3, 0x85, 0xff, 0xe0, 0xc3, 0xd0, 0x3c, 0x1c, 0xec, 0x85, 0x15,
|
0x70, 0x97, 0x47, 0xe4, 0x3e, 0x1c, 0x85, 0x7b, 0x70, 0x15, 0xd4, 0x1f, 0x7b, 0xda, 0x41, 0x23,
|
||||||
0x97, 0xdc, 0xba, 0xaa, 0xdd, 0xd3, 0xd5, 0x55, 0x51, 0xe0, 0x76, 0xdd, 0x54, 0x5c, 0x3d, 0xae,
|
0x66, 0x31, 0xbb, 0x7e, 0xd5, 0x7e, 0x5d, 0xef, 0x55, 0x3d, 0x19, 0xee, 0x34, 0x6d, 0x8d, 0xf5,
|
||||||
0x2b, 0xc5, 0x6a, 0x63, 0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, 0x87, 0xdf, 0xea, 0x96, 0x4e, 0xd4, 0x63, 0x06, 0xc9, 0xce, 0xc8,
|
||||||
0x1c, 0xe8, 0xcd, 0xba, 0xc6, 0xe7, 0x30, 0x29, 0x89, 0x65, 0x26, 0x59, 0x8a, 0x69, 0x1c, 0xac,
|
0xf6, 0x82, 0x4e, 0x63, 0x4f, 0x76, 0x96, 0x67, 0xf2, 0x02, 0xa6, 0x25, 0x47, 0x96, 0x31, 0x64,
|
||||||
0x67, 0xdb, 0x7b, 0x1b, 0x7b, 0xa3, 0x3e, 0x69, 0xf3, 0xde, 0xf5, 0xde, 0xed, 0xb9, 0x39, 0xa4,
|
0x74, 0x16, 0x7b, 0x9b, 0xf9, 0xee, 0xfe, 0x56, 0x7b, 0x94, 0x96, 0xb6, 0x1f, 0xcc, 0xdd, 0xbb,
|
||||||
0xc7, 0x4f, 0xf5, 0x69, 0x79, 0x29, 0x77, 0x24, 0x96, 0xf6, 0x34, 0x03, 0x56, 0xaf, 0x61, 0x3e,
|
0x0a, 0xdb, 0x43, 0x3a, 0x7c, 0x2a, 0xad, 0xe5, 0x25, 0xdb, 0x73, 0xba, 0xd6, 0xd6, 0x14, 0x88,
|
||||||
0x18, 0xc0, 0x05, 0x04, 0xdf, 0xe8, 0xe0, 0x2c, 0xd1, 0xa5, 0x1e, 0xbc, 0x92, 0x45, 0x7b, 0xf4,
|
0xde, 0xc0, 0x72, 0x44, 0x20, 0x2b, 0xf0, 0xbe, 0xf3, 0x83, 0x19, 0x89, 0x3c, 0x4a, 0xe2, 0x25,
|
||||||
0xc4, 0x80, 0x57, 0xfe, 0x4b, 0x2f, 0x69, 0xe0, 0xec, 0x63, 0x4b, 0xcd, 0x21, 0xa5, 0xef, 0x2d,
|
0x2b, 0xba, 0x61, 0x26, 0x0a, 0xbc, 0x76, 0x5f, 0x39, 0xc9, 0x39, 0x2c, 0xde, 0x57, 0x19, 0xff,
|
||||||
0xfd, 0xc3, 0xcd, 0xce, 0x37, 0xbf, 0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0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x17, 0x84, 0x7a, 0xa4,
|
0x6a, 0x76, 0x72, 0x22, 0x59, 0x6a, 0xdb, 0x03, 0xcb, 0xce, 0xdb, 0xc0, 0x1a, 0x05, 0x22, 0x39,
|
||||||
0x37, 0x04, 0x00, 0x00,
|
0x21, 0x4f, 0xc1, 0x97, 0x46, 0x08, 0xf9, 0x77, 0x9e, 0xd1, 0x7a, 0x54, 0x1b, 0x28, 0x2f, 0x21,
|
||||||
|
0xd4, 0xd2, 0x49, 0xff, 0xe8, 0xc8, 0x6a, 0x74, 0xf7, 0xa8, 0xda, 0x13, 0xbf, 0x84, 0xea, 0x57,
|
||||||
|
0xf6, 0xec, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xee, 0x3f, 0xc4, 0xdf, 0x04, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ func NewPostsEndpoints() []*api.Endpoint {
|
|||||||
// Client API for Posts service
|
// Client API for Posts service
|
||||||
|
|
||||||
type PostsService interface {
|
type PostsService interface {
|
||||||
|
// Index returns the posts index without content
|
||||||
|
Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error)
|
||||||
// Query currently only supports read by slug or timestamp, no listing.
|
// Query currently only supports read by slug or timestamp, no listing.
|
||||||
Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error)
|
Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error)
|
||||||
Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error)
|
Save(ctx context.Context, in *SaveRequest, opts ...client.CallOption) (*SaveResponse, error)
|
||||||
@@ -60,6 +62,16 @@ func NewPostsService(name string, c client.Client) PostsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *postsService) Index(ctx context.Context, in *IndexRequest, opts ...client.CallOption) (*IndexResponse, error) {
|
||||||
|
req := c.c.NewRequest(c.name, "Posts.Index", in)
|
||||||
|
out := new(IndexResponse)
|
||||||
|
err := c.c.Call(ctx, req, out, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *postsService) Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error) {
|
func (c *postsService) Query(ctx context.Context, in *QueryRequest, opts ...client.CallOption) (*QueryResponse, error) {
|
||||||
req := c.c.NewRequest(c.name, "Posts.Query", in)
|
req := c.c.NewRequest(c.name, "Posts.Query", in)
|
||||||
out := new(QueryResponse)
|
out := new(QueryResponse)
|
||||||
@@ -93,6 +105,8 @@ func (c *postsService) Delete(ctx context.Context, in *DeleteRequest, opts ...cl
|
|||||||
// Server API for Posts service
|
// Server API for Posts service
|
||||||
|
|
||||||
type PostsHandler interface {
|
type PostsHandler interface {
|
||||||
|
// Index returns the posts index without content
|
||||||
|
Index(context.Context, *IndexRequest, *IndexResponse) error
|
||||||
// Query currently only supports read by slug or timestamp, no listing.
|
// Query currently only supports read by slug or timestamp, no listing.
|
||||||
Query(context.Context, *QueryRequest, *QueryResponse) error
|
Query(context.Context, *QueryRequest, *QueryResponse) error
|
||||||
Save(context.Context, *SaveRequest, *SaveResponse) error
|
Save(context.Context, *SaveRequest, *SaveResponse) error
|
||||||
@@ -101,6 +115,7 @@ type PostsHandler interface {
|
|||||||
|
|
||||||
func RegisterPostsHandler(s server.Server, hdlr PostsHandler, opts ...server.HandlerOption) error {
|
func RegisterPostsHandler(s server.Server, hdlr PostsHandler, opts ...server.HandlerOption) error {
|
||||||
type posts interface {
|
type posts interface {
|
||||||
|
Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error
|
||||||
Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error
|
Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error
|
||||||
Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error
|
Save(ctx context.Context, in *SaveRequest, out *SaveResponse) error
|
||||||
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
Delete(ctx context.Context, in *DeleteRequest, out *DeleteResponse) error
|
||||||
@@ -116,6 +131,10 @@ type postsHandler struct {
|
|||||||
PostsHandler
|
PostsHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *postsHandler) Index(ctx context.Context, in *IndexRequest, out *IndexResponse) error {
|
||||||
|
return h.PostsHandler.Index(ctx, in, out)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *postsHandler) Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error {
|
func (h *postsHandler) Query(ctx context.Context, in *QueryRequest, out *QueryResponse) error {
|
||||||
return h.PostsHandler.Query(ctx, in, out)
|
return h.PostsHandler.Query(ctx, in, out)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ syntax = "proto3";
|
|||||||
package posts;
|
package posts;
|
||||||
|
|
||||||
service Posts {
|
service Posts {
|
||||||
|
// Index returns the posts index without content
|
||||||
|
rpc Index(IndexRequest) returns (IndexResponse) {}
|
||||||
// Query currently only supports read by slug or timestamp, no listing.
|
// Query currently only supports read by slug or timestamp, no listing.
|
||||||
rpc Query(QueryRequest) returns (QueryResponse) {}
|
rpc Query(QueryRequest) returns (QueryResponse) {}
|
||||||
rpc Save(SaveRequest) returns (SaveResponse) {}
|
rpc Save(SaveRequest) returns (SaveResponse) {}
|
||||||
@@ -22,6 +24,15 @@ message Post {
|
|||||||
string image = 19;
|
string image = 19;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message IndexRequest {
|
||||||
|
int64 limit = 1;
|
||||||
|
int64 offset = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message IndexResponse {
|
||||||
|
repeated Post posts = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Query posts. Acts as a listing when no id or slug provided.
|
// Query posts. Acts as a listing when no id or slug provided.
|
||||||
// Gets a single post by id or slug if any of them provided.
|
// Gets a single post by id or slug if any of them provided.
|
||||||
message QueryRequest {
|
message QueryRequest {
|
||||||
|
|||||||
Reference in New Issue
Block a user