Documentation
¶
Overview ¶
Package http implements the HTTP server handlers for different resource endpoints
Index ¶
- Variables
- func AdminUserNames(ctx context.Context, dbConn *sql.DB) ([]string, error)
- func AdminUsers(ctx context.Context, dbConn *sql.DB) ([]models.User, error)
- func Querier[T any](ctx context.Context, dbConn *sql.DB, query Query, logger *slog.Logger) ([]T, error)
- func VerifyOwnership(ctx context.Context, user string, clusterIDs []string, uuids []string, ...) bool
- type CEEMSServer
- type Config
- type Query
- type Response
- type WebConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrMaxQueryWindow = errors.New("maximum query window exceeded") ErrMalformedTimeStamp = errors.New("malformed timestamp") )
Functions ¶
func AdminUserNames ¶ added in v0.6.0
AdminUserNames returns a slice of admin users names.
func AdminUsers ¶ added in v0.6.0
AdminUsers returns a slice of admin users fetched from DB. Errors must always be checked to ensure no row scanning has failed.
Types ¶
type CEEMSServer ¶
type CEEMSServer struct {
// contains filtered or unexported fields
}
CEEMSServer struct implements HTTP server for stats.
func New ¶ added in v0.2.0
func New(c *Config) (*CEEMSServer, func(), error)
New creates new CEEMSServer struct instance.
func (*CEEMSServer) Shutdown ¶
func (s *CEEMSServer) Shutdown(ctx context.Context) error
Shutdown server.
func (*CEEMSServer) Start ¶
func (s *CEEMSServer) Start(_ context.Context) error
Start launches CEEMS HTTP server godoc
@title CEEMS API @version 1.0 @description OpenAPI specification (OAS) for the CEEMS REST API. @description @description See the Interactive Docs to try CEEMS API methods without writing code, and get @description the complete schema of resources exposed by the API. @description @description If basic auth is enabled, all the endpoints require authentication. @description @description All the endpoints, except `health`, `swagger`, `debug` and `demo`, @description must send a user-agent header. @description @description A demo instance of CEEMS API server is provided for the users to test. This @description instance is running at `https://ceems-demo.myaddr.tools:7443` and it is the @description default server that will serve the requests originating from current OAS client. @description @description Some of the valid users for this demo instance are: @description - arnold @description - betty @description - edna @description - gazoo @description - wilma @description @description Every request must contain a `X-Grafana-User` header with one of the usernames @description above as the value to the header. This is how CEEMS API server recognise the user. @description @description Some of the valid projects for this demo instance are: @description - bedrock @description - cornerstone @description @description Demo instance have CORS enabled to allow cross-domain communication from the browser. @description All responses have a wildcard same-origin which makes them completely public and @description accessible to everyone, including any code on any site. @description @description To test admin resources, users can use `admin` as `X-Grafana-User`. @description @description Timestamps must be specified in milliseconds, unless otherwise specified. @contact.name Mahendra Paipuri @contact.url https://github.com/mahendrapaipuri/ceems/issues @contact.email mahendra.paipuri@gmail.com @license.name GPL-3.0 license @license.url https://www.gnu.org/licenses/gpl-3.0.en.html @securityDefinitions.basic BasicAuth @host ceems-demo.myaddr.tools:7443 @BasePath /api/v1 @schemes https @externalDocs.url https://mahendrapaipuri.github.io/ceems/ @x-logo {"url": "https://raw.githubusercontent.com/mahendrapaipuri/ceems/refs/heads/main/website/static/img/logo.png", "altText": "CEEMS logo"}
type Response ¶
type Response[T any] struct { Status string `json:"status"` Data []T `extensions:"x-nullable,x-omitempty" json:"data"` ErrorType errorType `extensions:"x-nullable,x-omitempty" json:"errorType,omitempty"` Error string `extensions:"x-nullable,x-omitempty" json:"error,omitempty"` Warnings []string `extensions:"x-nullable,x-omitempty" json:"warnings,omitempty"` }
Response defines the response model of CEEMSAPIServer.
type WebConfig ¶
type WebConfig struct { Addresses []string WebSystemdSocket bool WebConfigFile string LandingConfig *web.LandingConfig EnableDebugServer bool UserHeaderNames []string ExternalURL *url.URL RoutePrefix string MaxQueryPeriod model.Duration RequestsLimit int CORSOrigin *regexp.Regexp URL string `yaml:"url"` HTTPClientConfig config.HTTPClientConfig `yaml:",inline"` }
WebConfig makes HTTP web config from CLI args.
func (*WebConfig) UnmarshalYAML ¶ added in v0.5.2
UnmarshalYAML implements the yaml.Unmarshaler interface.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.