hadith

package
v0.0.0-...-19cf849 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_LIMIT_PER_PAGE int = 50
	MAX_LIMIT_PER_PAGE     int = 150
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Book

type Book struct {
	Slug string `json:"book"`
	Name string `json:"name"`
	Size int    `json:"total"`
}

Book model to contain hadith book

type Hadith

type Hadith struct {
	Number    int    `json:"number"`
	Text      string `json:"arab"`
	Translate string `json:"id"`
}

Hadith model to contain hadith text

type HadithCollection

type HadithCollection map[string][]Hadith

HadithCollextion an alias to collection of hadith from all hadith book

type Handler

type Handler interface {
	GetAvailableBooks(c *fiber.Ctx) error
	GetHadithByBook(c *fiber.Ctx) error
	GetHadithByNumber(c *fiber.Ctx) error
	GetHadithRandom(c *fiber.Ctx) error
}

Handler contains method for fiber route handlers

func NewHandler

func NewHandler(service Service) Handler

NewHandler is a function to instantiate new handler object

type Repository

type Repository interface {
	GetAllBook() []Book
	GetAllHadith() HadithCollection
}

Repository contains method to interact with data source

func NewRepository

func NewRepository(data embed.FS) Repository

NewRepository is a function to instantiate new repository object

this function also retrieve all content of json files that containing collection of hadith.
retrieved contents stored to repository object properties and used as the data source.

type Service

type Service interface {
	GetAllAvailableBooks() []Book
	GetHadithByBook(bookName string, offset, limit int) (Book, []Hadith, error)
	GetHadithByNumber(bookName string, number int) (Book, Hadith, error)
	GetHadithRandom() (Book, Hadith, error)
}

Service contains all business logic method

func NewService

func NewService(repository Repository) Service

NewService is a function to instantiate new service object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL