httpserver

package
v0.0.0-...-bd820ff Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingMobileBrowser = errors.New("browser does not have a matching mobile browser")

Functions

func GenericErrorFn

func GenericErrorFn(ctx context.Context, statusCode int, w http.ResponseWriter, err error)

GenericErrorFn is a reusable method for the middleware layers that they can use to get well structured JSON output for BasicErrorModel.

func GetDesktopsMobileProduct

func GetDesktopsMobileProduct(browser backend.BrowserPathParam) (backend.BrowserPathParam, error)

GetDesktopsMobileProduct returns the mobile version of the given desktop browser.

func NewHTTPServer

func NewHTTPServer(
	port string,
	baseURL *url.URL,
	metadataStorer WebFeatureMetadataStorer,
	wptMetricsStorer WPTMetricsStorer,
	rawBytesDataCacher RawBytesDataCacher,
	routeCacheOptions RouteCacheOptions,
	userGitHubClientFactory UserGitHubClientFactory,
	preRequestValidationMiddlewares []func(http.Handler) http.Handler,
	authMiddleware func(http.Handler) http.Handler) *http.Server

Types

type GetFeatureResultVisitor

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

func (*GetFeatureResultVisitor) VisitMovedFeature

func (*GetFeatureResultVisitor) VisitRegularFeature

func (v *GetFeatureResultVisitor) VisitRegularFeature(ctx context.Context,
	result backendtypes.RegularFeatureResult) error

func (*GetFeatureResultVisitor) VisitSplitFeature

type GitHubUserClient

type GitHubUserClient interface {
	GetCurrentUser(ctx context.Context) (*gh.GitHubUser, error)
	ListEmails(ctx context.Context) ([]*gh.UserEmail, error)
}

type MissingOneBrowserParams

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

func PrepareMissingOneBrowserParams

func PrepareMissingOneBrowserParams(
	targetBrowserParam backend.BrowserPathParam,
	otherBrowsersParam []backend.BrowserPathParam,
	includeMobileBrowsers bool,
) (*MissingOneBrowserParams, error)

PrepareMissingOneBrowserParams takes the raw request arguments for "missing in one browser" requests and formats them.

type RawBytesDataCacher

type RawBytesDataCacher interface {
	// Cache stores a value associated with a key in the cache.
	Cache(context.Context, string, []byte, ...cachetypes.CacheOption) error
	// Get retrieves a value from the cache by its key.
	Get(context.Context, string) ([]byte, error)
}

RawBytesDataCacher defines an interface for caching raw byte data. This interface is intended for use in scenarios where data needs to be cached as raw bytes, rather than structured data types. Implementations of this interface should provide methods to store and retrieve byte slices associated with string keys. Currently implemented by the valkey cache layer.

type RouteCacheOptions

type RouteCacheOptions struct {
	// AggregatedFeatureStatsOptions applies cache options for routes that only contain stats on features.
	// Any routes with multiple data sources are not included (e.g. WPT Metrics)
	AggregatedFeatureStatsOptions []cachetypes.CacheOption
}

RouteCacheOptions contains options for caching routes.

type Server

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

func (*Server) CreateSavedSearch

CreateSavedSearch implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) CreateSubscription

nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) DeleteNotificationChannel

DeleteNotificationChannel handles the DELETE request to /v1/users/me/notification-channels/{channel_id}. nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) DeleteSubscription

nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) GetFeature

GetFeature implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) GetFeatureMetadata

GetFeatureMetadata implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) GetNotificationChannel

GetNotificationChannel handles the GET request to /v1/users/me/notification-channels/{channel_id}. nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) GetSavedSearch

GetSavedSearch implements backend.StrictServerInterface. nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) GetSubscription

nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) ListAggregatedBaselineStatusCounts

ListAggregatedBaselineStatusCounts implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) ListAggregatedFeatureSupport

ListAggregatedFeatureSupport implements backend.StrictServerInterface. nolint: ireturn // Signature generated from openapi

func (*Server) ListAggregatedWPTMetrics

ListAggregatedWPTMetrics implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) ListChromeDailyUsageStats

ListChromeDailyUsageStats implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) ListFeatureWPTMetrics

ListFeatureWPTMetrics implements backend.StrictServerInterface. nolint: revive, ireturn // Name generated from openapi

func (*Server) ListFeatures

ListFeatures implements backend.StrictServerInterface. nolint:ireturn // Expected ireturn for openapi generation.

func (*Server) ListMissingOneImplementationCounts

ListMissingOneImplementationCounts implements backend.StrictServerInterface. nolint: ireturn // Signature generated from openapi

func (*Server) ListMissingOneImplementationFeatures

ListMissingOneImplementationFeatures implements backend.StrictServerInterface. nolint: ireturn // Signature generated from openapi

func (*Server) ListNotificationChannels

ListNotificationChannels handles the GET request to /v1/users/me/notification-channels. nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) ListSubscriptions

nolint:ireturn, revive // Expected ireturn for openapi generation.

func (*Server) ListUserSavedSearches

ListUserSavedSearches implements backend.StrictServerInterface. nolint:ireturn // Expected ireturn for openapi generation.

func (*Server) PingUser

PingUser implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) PutUserSavedSearchBookmark

PutUserSavedSearchBookmark implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) RemoveSavedSearch

RemoveSavedSearch implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) RemoveUserSavedSearchBookmark

RemoveUserSavedSearchBookmark implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) UpdateSavedSearch

UpdateSavedSearch implements backend.StrictServerInterface. nolint: ireturn // Name generated from openapi

func (*Server) UpdateSubscription

nolint:ireturn, revive // Expected ireturn for openapi generation.

type UserCheckResult

type UserCheckResult[T any] struct {
	User     *auth.User
	Response T
}

UserCheckResult represents either a successful user retrieval or an error response.

func CheckAuthenticatedUser

func CheckAuthenticatedUser[T any](
	ctx context.Context,
	operation string,
	newErrorResponse func(code int, message string) T) UserCheckResult[T]

CheckAuthenticatedUser retrieves the authenticated user from the context. If the user is not found, it returns an error response.

type UserGitHubClient

type UserGitHubClient struct {
	GitHubUserClient
}

type UserGitHubClientFactory

type UserGitHubClientFactory func(token string) *UserGitHubClient

type WPTMetricsStorer

type WPTMetricsStorer interface {
	ListMetricsForFeatureIDBrowserAndChannel(
		ctx context.Context,
		featureID string,
		browser string,
		channel string,
		metricView backend.MetricViewPathParam,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string) ([]backend.WPTRunMetric, *string, error)
	ListMetricsOverTimeWithAggregatedTotals(
		ctx context.Context,
		featureIDs []string,
		browser string,
		channel string,
		metricView backend.MetricViewPathParam,
		startAt, endAt time.Time,
		pageSize int,
		pageToken *string,
	) ([]backend.WPTRunMetric, *string, error)
	ListChromeDailyUsageStats(
		ctx context.Context,
		featureID string,
		startAt, endAt time.Time,
		pageSize int,
		pageToken *string,
	) ([]backend.ChromeUsageStat, *string, error)
	FeaturesSearch(
		ctx context.Context,
		pageToken *string,
		pageSize int,
		searchNode *searchtypes.SearchNode,
		sortOrder *backend.ListFeaturesParamsSort,
		wptMetricType backend.WPTMetricView,
		browsers []backend.BrowserPathParam,
	) (*backend.FeaturePage, error)
	GetFeature(
		ctx context.Context,
		featureID string,
		wptMetricType backend.WPTMetricView,
		browsers []backend.BrowserPathParam,
	) (*backendtypes.GetFeatureResult, error)
	ListBrowserFeatureCountMetric(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*backend.BrowserReleaseFeatureMetricsPage, error)
	GetIDFromFeatureKey(
		ctx context.Context,
		featureID string,
	) (*string, error)
	ListMissingOneImplCounts(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		otherBrowsers []string,
		startAt, endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*backend.BrowserReleaseFeatureMetricsPage, error)
	ListMissingOneImplementationFeatures(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		otherBrowsers []string,
		targetDate time.Time,
		pageSize int,
		pageToken *string,
	) (*backend.MissingOneImplFeaturesPage, error)
	ListBaselineStatusCounts(
		ctx context.Context,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*backend.BaselineStatusMetricsPage, error)
	CreateUserSavedSearch(ctx context.Context, userID string,
		savedSearch backend.SavedSearch) (*backend.SavedSearchResponse, error)
	DeleteUserSavedSearch(ctx context.Context, userID, savedSearchID string) error
	GetSavedSearch(ctx context.Context, savedSearchID string, userID *string) (*backend.SavedSearchResponse, error)
	ListUserSavedSearches(
		ctx context.Context,
		userID string,
		pageSize int,
		pageToken *string,
	) (*backend.UserSavedSearchPage, error)
	UpdateUserSavedSearch(
		ctx context.Context,
		savedSearchID string,
		userID string,
		savedSearch *backend.SavedSearchUpdateRequest,
	) (*backend.SavedSearchResponse, error)
	PutUserSavedSearchBookmark(
		ctx context.Context,
		userID string,
		savedSearchID string,
	) error
	RemoveUserSavedSearchBookmark(
		ctx context.Context,
		userID string,
		savedSearchID string,
	) error
	SyncUserProfileInfo(ctx context.Context,
		userProfile backendtypes.UserProfile) error
	GetNotificationChannel(ctx context.Context,
		userID, channelID string) (*backend.NotificationChannelResponse, error)
	ListNotificationChannels(ctx context.Context,
		userID string, pageSize int, pageToken *string) (*backend.NotificationChannelPage, error)
	DeleteNotificationChannel(ctx context.Context,
		userID, channelID string) error
	CreateSavedSearchSubscription(ctx context.Context, userID string,
		subscription backend.Subscription) (*backend.SubscriptionResponse, error)
	DeleteSavedSearchSubscription(ctx context.Context, userID, subscriptionID string) error
	GetSavedSearchSubscription(ctx context.Context,
		userID, subscriptionID string) (*backend.SubscriptionResponse, error)
	ListSavedSearchSubscriptions(ctx context.Context,
		userID string, pageSize int, pageToken *string) (*backend.SubscriptionPage, error)
	UpdateSavedSearchSubscription(ctx context.Context, userID, subscriptionID string,
		req backend.UpdateSubscriptionRequest) (*backend.SubscriptionResponse, error)
}

type WebFeatureMetadataStorer

type WebFeatureMetadataStorer interface {
	GetFeatureMetadata(
		ctx context.Context,
		featureID string,
	) (*backend.FeatureMetadata, error)
}

Jump to

Keyboard shortcuts

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