Documentation ¶
Index ¶
- Constants
- Variables
- func FailureResponse(ctx context.Context, err error) render.Renderer
- func GenerateResponse(ctx context.Context, data any, err error) render.Renderer
- func GetOrganizationByID(ctx context.Context, organizationRepo repository.OrganizationRepository, ...) (*entity.Organization, error)
- func GetProjectByID(ctx context.Context, projectRepo repository.ProjectRepository, id uint) (*entity.Project, error)
- func GetSourceByID(ctx context.Context, sourceRepo repository.SourceRepository, id uint) (*entity.Source, error)
- func GetStackByID(ctx context.Context, stackRepo repository.StackRepository, id uint) (*entity.Stack, error)
- func HandleResult(w http.ResponseWriter, r *http.Request, ctx context.Context, err error, ...)
- func SuccessResponse(ctx context.Context, data any) render.Renderer
- type Duration
- type Payload
- type Response
Constants ¶
View Source
const SuccessMessage = "OK"
SuccessMessage is the default success message for successful responses.
Variables ¶
Functions ¶
func FailureResponse ¶
FailureResponse creates a response renderer for a failed request.
func GenerateResponse ¶
Response creates a standard API response renderer.
func GetOrganizationByID ¶
func GetOrganizationByID(ctx context.Context, organizationRepo repository.OrganizationRepository, id uint) (*entity.Organization, error)
func GetProjectByID ¶
func GetProjectByID(ctx context.Context, projectRepo repository.ProjectRepository, id uint) (*entity.Project, error)
func GetSourceByID ¶
func GetSourceByID(ctx context.Context, sourceRepo repository.SourceRepository, id uint) (*entity.Source, error)
func GetStackByID ¶
func GetStackByID(ctx context.Context, stackRepo repository.StackRepository, id uint) (*entity.Stack, error)
func HandleResult ¶
Types ¶
type Duration ¶
Duration is a custom type that represents a duration of time.
func (Duration) MarshalJSON ¶
MarshalJSON customizes JSON representation of the Duration type.
type Payload ¶
type Payload interface {
Decode(*http.Request) error // Decode returns the payload object with the decoded
}
Payload is an interface for incoming requests payloads Each handler should implement this interface to parse payloads
type Response ¶
type Response struct { Success bool `json:"success" yaml:"success"` // Indicates success status. Message string `json:"message" yaml:"message"` // Descriptive message. Data any `json:"data,omitempty" yaml:"data,omitempty"` // Data payload. TraceID string `json:"traceID,omitempty" yaml:"traceID,omitempty"` // Trace identifier. StartTime *time.Time `json:"startTime,omitempty" yaml:"startTime,omitempty"` // Request start time. EndTime *time.Time `json:"endTime,omitempty" yaml:"endTime,omitempty"` // Request end time. CostTime Duration `json:"costTime,omitempty" yaml:"costTime,omitempty"` // Time taken for the request. }
response defines the structure for API response payloads.
Click to show internal directories.
Click to hide internal directories.