mirror of
https://github.com/kevin-DL/services.git
synced 2026-01-20 22:45:09 +00:00
add sunnah api (#210)
This commit is contained in:
1304
sunnah/proto/sunnah.pb.go
Normal file
1304
sunnah/proto/sunnah.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
144
sunnah/proto/sunnah.pb.micro.go
Normal file
144
sunnah/proto/sunnah.pb.micro.go
Normal file
@@ -0,0 +1,144 @@
|
||||
// Code generated by protoc-gen-micro. DO NOT EDIT.
|
||||
// source: proto/sunnah.proto
|
||||
|
||||
package sunnah
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
math "math"
|
||||
)
|
||||
|
||||
import (
|
||||
context "context"
|
||||
api "github.com/micro/micro/v3/service/api"
|
||||
client "github.com/micro/micro/v3/service/client"
|
||||
server "github.com/micro/micro/v3/service/server"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ api.Endpoint
|
||||
var _ context.Context
|
||||
var _ client.Option
|
||||
var _ server.Option
|
||||
|
||||
// Api Endpoints for Sunnah service
|
||||
|
||||
func NewSunnahEndpoints() []*api.Endpoint {
|
||||
return []*api.Endpoint{}
|
||||
}
|
||||
|
||||
// Client API for Sunnah service
|
||||
|
||||
type SunnahService interface {
|
||||
Collections(ctx context.Context, in *CollectionsRequest, opts ...client.CallOption) (*CollectionsResponse, error)
|
||||
Books(ctx context.Context, in *BooksRequest, opts ...client.CallOption) (*BooksResponse, error)
|
||||
Chapters(ctx context.Context, in *ChaptersRequest, opts ...client.CallOption) (*ChaptersResponse, error)
|
||||
Hadiths(ctx context.Context, in *HadithsRequest, opts ...client.CallOption) (*HadithsResponse, error)
|
||||
}
|
||||
|
||||
type sunnahService struct {
|
||||
c client.Client
|
||||
name string
|
||||
}
|
||||
|
||||
func NewSunnahService(name string, c client.Client) SunnahService {
|
||||
return &sunnahService{
|
||||
c: c,
|
||||
name: name,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *sunnahService) Collections(ctx context.Context, in *CollectionsRequest, opts ...client.CallOption) (*CollectionsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Sunnah.Collections", in)
|
||||
out := new(CollectionsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sunnahService) Books(ctx context.Context, in *BooksRequest, opts ...client.CallOption) (*BooksResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Sunnah.Books", in)
|
||||
out := new(BooksResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sunnahService) Chapters(ctx context.Context, in *ChaptersRequest, opts ...client.CallOption) (*ChaptersResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Sunnah.Chapters", in)
|
||||
out := new(ChaptersResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *sunnahService) Hadiths(ctx context.Context, in *HadithsRequest, opts ...client.CallOption) (*HadithsResponse, error) {
|
||||
req := c.c.NewRequest(c.name, "Sunnah.Hadiths", in)
|
||||
out := new(HadithsResponse)
|
||||
err := c.c.Call(ctx, req, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Sunnah service
|
||||
|
||||
type SunnahHandler interface {
|
||||
Collections(context.Context, *CollectionsRequest, *CollectionsResponse) error
|
||||
Books(context.Context, *BooksRequest, *BooksResponse) error
|
||||
Chapters(context.Context, *ChaptersRequest, *ChaptersResponse) error
|
||||
Hadiths(context.Context, *HadithsRequest, *HadithsResponse) error
|
||||
}
|
||||
|
||||
func RegisterSunnahHandler(s server.Server, hdlr SunnahHandler, opts ...server.HandlerOption) error {
|
||||
type sunnah interface {
|
||||
Collections(ctx context.Context, in *CollectionsRequest, out *CollectionsResponse) error
|
||||
Books(ctx context.Context, in *BooksRequest, out *BooksResponse) error
|
||||
Chapters(ctx context.Context, in *ChaptersRequest, out *ChaptersResponse) error
|
||||
Hadiths(ctx context.Context, in *HadithsRequest, out *HadithsResponse) error
|
||||
}
|
||||
type Sunnah struct {
|
||||
sunnah
|
||||
}
|
||||
h := &sunnahHandler{hdlr}
|
||||
return s.Handle(s.NewHandler(&Sunnah{h}, opts...))
|
||||
}
|
||||
|
||||
type sunnahHandler struct {
|
||||
SunnahHandler
|
||||
}
|
||||
|
||||
func (h *sunnahHandler) Collections(ctx context.Context, in *CollectionsRequest, out *CollectionsResponse) error {
|
||||
return h.SunnahHandler.Collections(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *sunnahHandler) Books(ctx context.Context, in *BooksRequest, out *BooksResponse) error {
|
||||
return h.SunnahHandler.Books(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *sunnahHandler) Chapters(ctx context.Context, in *ChaptersRequest, out *ChaptersResponse) error {
|
||||
return h.SunnahHandler.Chapters(ctx, in, out)
|
||||
}
|
||||
|
||||
func (h *sunnahHandler) Hadiths(ctx context.Context, in *HadithsRequest, out *HadithsResponse) error {
|
||||
return h.SunnahHandler.Hadiths(ctx, in, out)
|
||||
}
|
||||
158
sunnah/proto/sunnah.proto
Normal file
158
sunnah/proto/sunnah.proto
Normal file
@@ -0,0 +1,158 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package sunnah;
|
||||
|
||||
option go_package = "./proto;sunnah";
|
||||
|
||||
service Sunnah {
|
||||
rpc Collections(CollectionsRequest) returns (CollectionsResponse) {}
|
||||
rpc Books(BooksRequest) returns (BooksResponse) {}
|
||||
rpc Chapters(ChaptersRequest) returns (ChaptersResponse) {}
|
||||
rpc Hadiths(HadithsRequest) returns (HadithsResponse) {}
|
||||
}
|
||||
|
||||
message Collection {
|
||||
// Name of the collection e.g bukhari
|
||||
string name = 1;
|
||||
// Title of the collection e.g Sahih al-Bukhari
|
||||
string title = 2;
|
||||
// Arabic title if available
|
||||
string arabic_title = 3;
|
||||
// An introduction explaining the collection
|
||||
string summary = 4;
|
||||
// Total hadiths in the collection
|
||||
int32 hadiths = 5;
|
||||
}
|
||||
|
||||
message Book {
|
||||
// number of the book e.g 1
|
||||
int32 id = 1;
|
||||
// name of the book
|
||||
string name = 2;
|
||||
// arabic name of the book
|
||||
string arabic_name = 3;
|
||||
// number of hadiths in the book
|
||||
int32 hadiths = 4;
|
||||
}
|
||||
|
||||
message Chapter {
|
||||
// the chapter id e.g 1
|
||||
int32 id = 1;
|
||||
// the chapter key e.g 1.00
|
||||
string key = 2;
|
||||
// the book number
|
||||
int32 book = 3;
|
||||
// title of the chapter
|
||||
string title = 4;
|
||||
// arabic title
|
||||
string arabic_title = 5;
|
||||
}
|
||||
|
||||
message Hadith {
|
||||
// hadith id
|
||||
int32 id = 1;
|
||||
// the chapter id
|
||||
int32 chapter = 2;
|
||||
// the chapter key
|
||||
string chapter_key = 3;
|
||||
// the chapter title
|
||||
string chapter_title = 4;
|
||||
// the arabic chapter title
|
||||
string arabic_chapter_title = 5;
|
||||
// hadith text
|
||||
string text = 6;
|
||||
// the arabic text
|
||||
string arabic_text = 7;
|
||||
}
|
||||
|
||||
// Get a list of available collections. A collection is
|
||||
// a compilation of hadiths collected and written by an author.
|
||||
message CollectionsRequest {
|
||||
// The page in the pagination
|
||||
int32 page = 1;
|
||||
// Number of collections to limit to
|
||||
int32 limit = 2;
|
||||
}
|
||||
|
||||
message CollectionsResponse {
|
||||
repeated Collection collections = 1;
|
||||
}
|
||||
|
||||
// Get a list of books from within a collection. A book can contain many chapters
|
||||
// each with its own hadiths.
|
||||
message BooksRequest {
|
||||
// Name of the collection
|
||||
string collection = 1;
|
||||
// The page in the pagination
|
||||
int32 page = 2;
|
||||
// Limit the number of books returned
|
||||
int32 limit = 3;
|
||||
}
|
||||
|
||||
message BooksResponse {
|
||||
// Name of the collection
|
||||
string collection = 1;
|
||||
// The total overall books
|
||||
int32 total = 2;
|
||||
// The page requested
|
||||
int32 page = 3;
|
||||
// The limit specified
|
||||
int32 limit = 4;
|
||||
// A list of books
|
||||
repeated Book books = 5;
|
||||
}
|
||||
|
||||
// Get all the chapters of a given book within a collection.
|
||||
message ChaptersRequest {
|
||||
// name of the collection
|
||||
string collection = 1;
|
||||
// number of the book
|
||||
int32 book = 2;
|
||||
// The page in the pagination
|
||||
int32 page = 3;
|
||||
// Limit the number of chapters returned
|
||||
int32 limit = 4;
|
||||
}
|
||||
|
||||
message ChaptersResponse {
|
||||
// name of the collection
|
||||
string collection = 1;
|
||||
// number of the book
|
||||
int32 book = 2;
|
||||
// The page in the pagination
|
||||
int32 page = 3;
|
||||
// Limit the number of chapters returned
|
||||
int32 limit = 4;
|
||||
// Total chapters in the book
|
||||
int32 total = 5;
|
||||
// The chapters of the book
|
||||
repeated Chapter chapters = 6;
|
||||
}
|
||||
|
||||
// Hadiths returns a list of hadiths and their corresponding text for a
|
||||
// given book within a collection.
|
||||
message HadithsRequest {
|
||||
// name of the collection
|
||||
string collection = 1;
|
||||
// number of the book
|
||||
int32 book = 2;
|
||||
// The page in the pagination
|
||||
int32 page = 3;
|
||||
// Limit the number of hadiths
|
||||
int32 limit = 4;
|
||||
}
|
||||
|
||||
message HadithsResponse {
|
||||
// name of the collection
|
||||
string collection = 1;
|
||||
// number of the book
|
||||
int32 book = 2;
|
||||
// The page in the pagination
|
||||
int32 page = 3;
|
||||
// Limit the number of hadiths returned
|
||||
int32 limit = 4;
|
||||
// Total hadiths in the book
|
||||
int32 total = 5;
|
||||
// The hadiths of the book
|
||||
repeated Hadith hadiths = 7;
|
||||
}
|
||||
Reference in New Issue
Block a user