api

package
v0.0.0-...-8cf3990 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReturnError

func ReturnError(w http.ResponseWriter, err error) bool

ReturnError produces an error response with HTTP status code 500 if the given error is non-nil. Otherwise, nothing is done and false is returned.

func ReturnJSON

func ReturnJSON(w http.ResponseWriter, code int, data any)

ReturnJSON is a convenience function for HTTP handlers returning JSON data. The `code` argument specifies the HTTP response code, usually 200.

func Server

func Server(validator gopherpolicy.Validator, storageInterface storage.Storage) error

Server Set up and start the API server, hooking it up to the API router

Types

type EventList

type EventList struct {
	NextURL string              `json:"next,omitempty"`
	PrevURL string              `json:"previous,omitempty"`
	Events  []*hermes.ListEvent `json:"events"`
	Total   int                 `json:"total"`
}

EventList is the model for JSON returned by the ListEvents API call

type VersionData

type VersionData struct {
	Status string            `json:"status"`
	ID     string            `json:"id"`
	Links  []versionLinkData `json:"links"`
}

VersionData is used by version advertisement handlers.

func NewV1Handler

func NewV1Handler(validator gopherpolicy.Validator, storageInterface storage.Storage) (http.Handler, VersionData)

NewV1Handler creates a http.Handler that serves the Hermes v1 API. It also returns the VersionData for this API version which is needed for the version advertisement on "GET /".

Jump to

Keyboard shortcuts

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