handler

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MPL-2.0 Imports: 9 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPost

func GetPost(getHandler, postHandler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

GetPost is a helper function to assign different handlers depending on the HTTP method.

func MethodNotAllowedHandler

func MethodNotAllowedHandler(w http.ResponseWriter, _ *http.Request)

MethodNotAllowedHandler returns a 405 Method Not Allowed error.

func VerifyUser

func VerifyUser(verifyFunc func(context.Context, []*x509.Certificate) (*user.User, error), r *http.Request) (*user.User, error)

VerifyUser checks if the user is authorized to access the API.

func WriteJSON

func WriteJSON(w http.ResponseWriter, v interface{})

WriteJSON writes a JSend response to the given http.ResponseWriter.

func WriteJSONError

func WriteJSONError(w http.ResponseWriter, errorString string, httpErrorCode int)

WriteJSONError writes a JSend error response to the given http.ResponseWriter.

func WriteJSONFailure

func WriteJSONFailure(w http.ResponseWriter, v interface{}, message string, httpErrorCode int)

WriteJSONFailure writes a JSend failure response to the given http.ResponseWriter.

Types

type ClientAPI

type ClientAPI interface {
	SetManifest(ctx context.Context, rawManifest []byte) (recoverySecretMap map[string][]byte, err error)
	GetCertQuote(ctx context.Context, nonce []byte) (cert string, certQuote []byte, err error)
	GetManifestSignature(context.Context) (manifestSignatureRootECDSA, manifest []byte, err error)
	GetSecrets(ctx context.Context, requestedSecrets []string, requestUser *user.User) (map[string]manifest.Secret, error)
	GetStatus(context.Context) (statusCode state.State, status string, err error)
	GetUpdateLog(context.Context) (updateLog []string, err error)
	Recover(ctx context.Context, encryptionKey []byte) (int, error)
	SignQuote(ctx context.Context, quote []byte) (signature []byte, tcbStatus string, err error)
	VerifyUser(ctx context.Context, clientCerts []*x509.Certificate) (*user.User, error)
	UpdateManifest(ctx context.Context, rawUpdateManifest []byte, updater *user.User) error
	WriteSecrets(ctx context.Context, secrets map[string]manifest.UserSecret, updater *user.User) error
	FeatureEnabled(ctx context.Context, feature string) bool
}

ClientAPI is the interface implementing the backend logic of the REST API.

type GeneralResponse

type GeneralResponse struct {
	Status  string      `json:"status"`
	Data    interface{} `json:"data"`
	Message string      `json:"message,omitempty"` // only used when status = "error"
}

GeneralResponse is a wrapper for all our REST API responses to follow the JSend style: https://github.com/omniti-labs/jsend

Jump to

Keyboard shortcuts

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