🎨 Format static use case
This commit is contained in:
parent
ed87027846
commit
5adcb66862
|
@ -7,5 +7,6 @@ import (
|
|||
)
|
||||
|
||||
type UseCase interface {
|
||||
// Do search static on path and returns Static domain if exist.
|
||||
Do(ctx context.Context, path string) (*domain.Static, error)
|
||||
}
|
||||
|
|
|
@ -11,19 +11,19 @@ import (
|
|||
)
|
||||
|
||||
type staticUseCase struct {
|
||||
statics static.Repository
|
||||
store static.Repository
|
||||
}
|
||||
|
||||
func NewStaticUseCase(statics static.Repository) static.UseCase {
|
||||
func NewStaticUseCase(store static.Repository) static.UseCase {
|
||||
return &staticUseCase{
|
||||
statics: statics,
|
||||
store: store,
|
||||
}
|
||||
}
|
||||
|
||||
func (ucase *staticUseCase) Do(ctx context.Context, p string) (*domain.Static, error) {
|
||||
p = strings.TrimPrefix(path.Clean(p), "/")
|
||||
|
||||
s, err := ucase.statics.Get(ctx, p)
|
||||
s, err := ucase.store.Get(ctx, p)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot get static file: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue