👔 Created basic page use case implementation
This commit is contained in:
parent
79d8fa66f6
commit
9bd2f81c46
|
@ -0,0 +1,30 @@
|
|||
package usecase
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
|
||||
"source.toby3d.me/toby3d/home/internal/domain"
|
||||
"source.toby3d.me/toby3d/home/internal/page"
|
||||
)
|
||||
|
||||
type pageUseCase struct {
|
||||
pages page.Repository
|
||||
}
|
||||
|
||||
func NewPageUseCase(pages page.Repository) page.UseCase {
|
||||
return &pageUseCase{
|
||||
pages: pages,
|
||||
}
|
||||
}
|
||||
|
||||
func (ucase *pageUseCase) Do(ctx context.Context, lang language.Tag, path string) (*domain.Page, error) {
|
||||
page, err := ucase.pages.Get(ctx, lang, path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot find '%s' page: %w", path, err)
|
||||
}
|
||||
|
||||
return page, nil
|
||||
}
|
Loading…
Reference in New Issue