server

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package server provides HTTP handlers and middlewares for application.

Index

Constants

This section is empty.

Variables

View Source
var Asset embed.FS

Functions

func NewContextWithUser

func NewContextWithUser(ctx context.Context, user warnly.User) context.Context

NewContextWithUser is a helper function to add user to context.

Types

type AlertsHandler added in v0.5.0

type AlertsHandler struct {
	*BaseHandler
	// contains filtered or unexported fields
}

AlertsHandler is a handler for alerts.

func NewAlertsHandler added in v0.5.0

func NewAlertsHandler(alertService warnly.AlertService, logger *slog.Logger) *AlertsHandler

NewAlertsHandler is a constructor of AlertsHandler.

func (*AlertsHandler) CreateAlert added in v0.5.0

func (h *AlertsHandler) CreateAlert(w http.ResponseWriter, r *http.Request)

CreateAlert is a handler for POST /alerts.

func (*AlertsHandler) CreateAlertGet added in v0.5.0

func (h *AlertsHandler) CreateAlertGet(w http.ResponseWriter, r *http.Request)

CreateAlertGet is a handler for GET /alerts/new.

func (*AlertsHandler) DeleteAlert added in v0.5.0

func (h *AlertsHandler) DeleteAlert(w http.ResponseWriter, r *http.Request)

DeleteAlert is a handler for DELETE /alerts/{id}.

func (*AlertsHandler) EditAlertGet added in v0.5.0

func (h *AlertsHandler) EditAlertGet(w http.ResponseWriter, r *http.Request)

EditAlertGet is a handler for GET /alerts/{id}/edit.

func (*AlertsHandler) ListAlerts added in v0.5.0

func (h *AlertsHandler) ListAlerts(w http.ResponseWriter, r *http.Request)

ListAlerts is a handler for GET /alerts.

func (*AlertsHandler) UpdateAlert added in v0.5.0

func (h *AlertsHandler) UpdateAlert(w http.ResponseWriter, r *http.Request)

UpdateAlert is a handler for PUT /alerts/{id}.

type Backend

type Backend struct {
	Now                 func() time.Time
	SessionStore        warnly.SessionStore
	UserStore           warnly.UserStore
	SessionService      warnly.SessionService
	EventService        warnly.EventService
	ProjectService      warnly.ProjectService
	SystemService       warnly.SystemService
	AlertService        warnly.AlertService
	NotificationService warnly.NotificationService
	OIDC                *OIDC
	Reg                 *prometheus.Registry
	Logger              *slog.Logger
	CookieStore         *session.CookieStore
	RememberSessionDays int
	IsHTTPS             bool
	IsDemo              bool
}

Backend is all services and associated parameters required to construct a Handler.

type BaseHandler

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

func NewBaseHandler

func NewBaseHandler(logger *slog.Logger) *BaseHandler

type ClientError

type ClientError interface {
	Error() string
	HTTPStatus() int
	Response() ingestResponseError
}

ClientError represents an error that should result in a specific HTTP status code and a structured JSON response body for the client.

type EventHandler

type EventHandler struct {
	// contains filtered or unexported fields
}

EventHandler ingests events via API.

func NewEventAPIHandler

func NewEventAPIHandler(svc warnly.EventService, logger *slog.Logger) *EventHandler

NewEventAPIHandler is a constructor of ventHandler.

func (*EventHandler) IngestEvent

func (h *EventHandler) IngestEvent(w http.ResponseWriter, r *http.Request)

IngestEvent ingests new event.

type Handler

type Handler struct {
	*http.ServeMux
}

Handler is a collection of all the service handlers.

func NewHandler

func NewHandler(b *Backend) (*Handler, error)

NewHandler initialize dependencies and returns router with attached routes.

type IngestError

type IngestError struct {
	Detail       string
	WrappedError error
	Causes       []string
	Status       int
}

func NewBadRequestError

func NewBadRequestError(detail string, originalErr error, causes ...string) *IngestError

NewBadRequestError creates a 400 Bad Request error, saving the optional original error.

func NewInvalidDSNError

func NewInvalidDSNError() *IngestError

NewInvalidDSNError creates a 400 error specifically for bad DSN/key.

func NewSizeLimitError

func NewSizeLimitError(detail string) *IngestError

NewSizeLimitError creates a 400 error for size limit exceeded.

func (*IngestError) Error

func (e *IngestError) Error() string

Error implements the error interface.

func (*IngestError) HTTPStatus

func (e *IngestError) HTTPStatus() int

HTTPStatus returns the HTTP status code for the response.

func (*IngestError) Response

func (e *IngestError) Response() ingestResponseError

Response returns the structured error response body.

func (*IngestError) Unwrap

func (e *IngestError) Unwrap() error

Unwrap allows errors.Unwrap to retrieve the original error.

type OIDC added in v0.2.0

type OIDC struct {
	ProviderName string
	Nonce        string
	Callback     string
	Provider     *capoidc.Provider
	Scopes       []string
	EmailMatches []*regexp.Regexp
	UsePkce      bool
}

type ProjectHandler

type ProjectHandler struct {
	*BaseHandler
	// contains filtered or unexported fields
}

ProjectHandler handles operations on project resource.

func NewProjectHandler

func NewProjectHandler(
	svc warnly.ProjectService,
	logger *slog.Logger,
) *ProjectHandler

NewProjectHandler is a constructor of projectHandler.

func (*ProjectHandler) AssignIssue

func (h *ProjectHandler) AssignIssue(w http.ResponseWriter, r *http.Request)

AssignIssue assigns an issue to a user.

func (*ProjectHandler) CreateProject

func (h *ProjectHandler) CreateProject(w http.ResponseWriter, r *http.Request)

CreateProject creates a new project.

func (*ProjectHandler) DeleteAssignment

func (h *ProjectHandler) DeleteAssignment(w http.ResponseWriter, r *http.Request)

DeleteAssignment deletes a user assignment for an issue.

func (*ProjectHandler) DeleteMessage

func (h *ProjectHandler) DeleteMessage(w http.ResponseWriter, r *http.Request)

DeleteMessage deletes a message (user comment for issue) by identifier in issue discussion.

func (*ProjectHandler) DeleteProject

func (h *ProjectHandler) DeleteProject(w http.ResponseWriter, r *http.Request)

DeleteProject is a method that deletes a project.

func (*ProjectHandler) GetDiscussions

func (h *ProjectHandler) GetDiscussions(w http.ResponseWriter, r *http.Request)

GetDiscussions retrieves discussions for an issue.

func (*ProjectHandler) GetIssue

func (h *ProjectHandler) GetIssue(w http.ResponseWriter, r *http.Request)

GetIssue renders issue page.

func (*ProjectHandler) GetPlatforms

func (h *ProjectHandler) GetPlatforms(w http.ResponseWriter, r *http.Request)

GetPlatforms renders possible project platforms.

func (*ProjectHandler) GettingStarted

func (h *ProjectHandler) GettingStarted(w http.ResponseWriter, r *http.Request)

GettingStarted renders getting started page.

func (*ProjectHandler) ListEvents

func (h *ProjectHandler) ListEvents(w http.ResponseWriter, r *http.Request)

ListEvents lists all events per specified issue. it handles "All Errors" page in issue details.

func (*ProjectHandler) ListFields

func (h *ProjectHandler) ListFields(w http.ResponseWriter, r *http.Request)

ListFields renders list of fields related to an issue with some statistics, e.g. how many times a field like browser or os was seen in events.

func (*ProjectHandler) ListProjects

func (h *ProjectHandler) ListProjects(w http.ResponseWriter, r *http.Request)

ListProjects returns a list of projects among with errors for last 24 hours.

func (*ProjectHandler) PostMessage

func (h *ProjectHandler) PostMessage(w http.ResponseWriter, r *http.Request)

PostMessage creates a new message (user comment) in issue discussion.

func (*ProjectHandler) ProjectDetails

func (h *ProjectHandler) ProjectDetails(w http.ResponseWriter, r *http.Request)

ProjectDetails renders project details page.

func (*ProjectHandler) ProjectSettings

func (h *ProjectHandler) ProjectSettings(w http.ResponseWriter, r *http.Request)

ProjectSettings is a method that renders project settings page.

func (*ProjectHandler) SearchProjectByName

func (h *ProjectHandler) SearchProjectByName(w http.ResponseWriter, r *http.Request)

SearchProjectByName is a method that searches projects by name.

Jump to

Keyboard shortcuts

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