handlers

package
v0.0.0-...-e705344 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHealthcheck

func GetHealthcheck(logger *slog.Logger) http.Handler

Declare a handler which writes a plain-text response with information about the application status.

Types

type BaseHandler

type BaseHandler struct {
	Logger *slog.Logger
	Config Config
}

func (*BaseHandler) LogRequest

func (h *BaseHandler) LogRequest(r *http.Request, operation string)

func (*BaseHandler) WithTimeout

func (h *BaseHandler) WithTimeout(r *http.Request) (context.Context, context.CancelFunc)

type CompanyHandler

type CompanyHandler struct {
	BaseHandler
	// contains filtered or unexported fields
}

func NewCompanyHandler

func NewCompanyHandler(
	logger *slog.Logger,
	config Config,
	companyRepository repository.CompanyRepository,
	timeProvider models.TimeProvider,
) *CompanyHandler

func (*CompanyHandler) Create

func (h *CompanyHandler) Create() http.Handler

CreateCompany creates a new company.

func (*CompanyHandler) Delete

func (h *CompanyHandler) Delete() http.Handler

DeleteCompany deletes an existing company by their unique identifier.

func (*CompanyHandler) Get

func (h *CompanyHandler) Get() http.Handler

GetCompany retrieves a single company by their unique identifier.

func (*CompanyHandler) List

func (h *CompanyHandler) List() http.Handler

ListCompanies retrieves a list of companies with optional filtering, sorting, and pagination.

func (*CompanyHandler) Update

func (h *CompanyHandler) Update() http.Handler

UpdateCompany updates an existing company by their unique identifier.

type CompanyInput

type CompanyInput struct {
	Name string `json:"name"`
}

type Config

type Config struct {
	Timeout         time.Duration
	MaxPageSize     int
	DefaultPageSize int
}

type ConfigItemHandler

type ConfigItemHandler struct {
	BaseHandler
	// contains filtered or unexported fields
}

func NewConfigItemHandler

func NewConfigItemHandler(
	logger *slog.Logger,
	config Config,
	ciRepository repository.ConfigItemRepository,
	timeProvider models.TimeProvider,
) *ConfigItemHandler

func (*ConfigItemHandler) Create

func (h *ConfigItemHandler) Create() http.Handler

CreateConfigItem creates a new ci.

func (*ConfigItemHandler) Delete

func (h *ConfigItemHandler) Delete() http.Handler

DeleteConfigItem deletes an existing ci by their unique identifier.

func (*ConfigItemHandler) Get

func (h *ConfigItemHandler) Get() http.Handler

GetConfigItem retrieves a single ci by their unique identifier.

func (*ConfigItemHandler) List

func (h *ConfigItemHandler) List() http.Handler

ListConfigItems retrieves a list of cis with optional filtering, sorting, and pagination.

func (*ConfigItemHandler) Update

func (h *ConfigItemHandler) Update() http.Handler

UpdateConfigItem updates an existing ci by their unique identifier.

type ConfigItemInput

type ConfigItemInput struct {
	Name string `json:"name"`
}

type IncidentHandler

type IncidentHandler struct {
	BaseHandler
	// contains filtered or unexported fields
}

func NewIncidentHandler

func NewIncidentHandler(
	logger *slog.Logger,
	config Config,
	incidentRepository repository.IncidentRepository,
	timeProvider models.TimeProvider,
) *IncidentHandler

func (*IncidentHandler) Create

func (h *IncidentHandler) Create() http.Handler

CreateIncident creates a new incident.

func (*IncidentHandler) Delete

func (h *IncidentHandler) Delete() http.Handler

DeleteIncident deletes an existing incident by their unique identifier.

func (*IncidentHandler) Get

func (h *IncidentHandler) Get() http.Handler

GetIncident retrieves a single incident by their unique identifier.

func (*IncidentHandler) List

func (h *IncidentHandler) List() http.Handler

ListIncidents retrieves a list of incidents with optional filtering, sorting, and pagination.

func (*IncidentHandler) Update

func (h *IncidentHandler) Update() http.Handler

UpdateIncident updates an existing incident by their unique identifier.

type IncidentInput

type IncidentInput struct {
	ID                  uuid.UUID          `json:"id"`
	CreatedAt           time.Time          `json:"created_at"`
	UpdatedAt           time.Time          `json:"updated_at"`
	ShortDescription    string             `json:"short_description"`
	Description         string             `json:"description"`
	ConfigurationItemID uuid.UUID          `json:"configuration_item_id"`
	CompanyID           uuid.UUID          `json:"company_id"`
	AssignedToID        uuid.NullUUID      `json:"assigned_to_id"`
	AssignedToName      string             `json:"assigned_to_name"`
	State               database.StateEnum `json:"state"`
}

type UserHandler

type UserHandler struct {
	BaseHandler
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(
	logger *slog.Logger,
	config Config,
	userRepository repository.UserRepository,
	timeProvider models.TimeProvider,
) *UserHandler

func (*UserHandler) Create

func (h *UserHandler) Create() http.Handler

creates a new user.

func (*UserHandler) Delete

func (h *UserHandler) Delete() http.Handler

Delete deletes an existing user by their unique identifier.

func (*UserHandler) Get

func (h *UserHandler) Get() http.Handler

Get retrieves a single user by their unique identifier.

func (*UserHandler) List

func (h *UserHandler) List() http.Handler

List retrieves a list of users with optional filtering, sorting, and pagination.

func (*UserHandler) Update

func (h *UserHandler) Update() http.Handler

Update updates an existing user by their unique identifier.

type UserInput

type UserInput struct {
	FirstName             string    `json:"first_name"`
	LastName              string    `json:"last_name"`
	Email                 string    `json:"email"`
	RoleID                uuid.UUID `json:"role_id"`
	DepartmentID          uuid.UUID `json:"department_id"`
	SendWelcomeEmail      bool      `json:"send_welcome_email"`
	RequirePasswordChange bool      `json:"require_password_change"`
}

Jump to

Keyboard shortcuts

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