usecase

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package usecase provides a minimal pattern for application use cases (application service layer). Use cases depend only on domain (domain errors, domain/port interfaces). Handlers call use cases with request context; use cases call repository ports and return domain errors. Dependency flow: handler → usecase → domain.port (implementations live in repositories or app).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetItemByID

func GetItemByID(ctx context.Context, repo port.GetByID, id string) (interface{}, error)

GetItemByID runs the "get item by ID" use case. It depends only on the domain port. Returned error is suitable for handler.HandleServiceError (e.g. domain.ErrNotFound).

Types

type Func

type Func func(ctx context.Context) error

Func adapts a function to Runner.

func (Func) Run

func (f Func) Run(ctx context.Context) error

Run calls f(ctx).

type Runner

type Runner interface {
	Run(ctx context.Context) error
}

Runner runs a use case with the given context. Return domain.ErrNotFound, domain.ErrUnauthorized, or other errors for the handler to map to HTTP responses via BaseHandler.HandleServiceError.

Jump to

Keyboard shortcuts

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