http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentType represents JSON content type.
	ContentType = "application/json"
	OCSPType    = "application/ocsp-response"
)

Variables

View Source
var (
	// ErrEmptySerialNo indicates that the serial number is empty.
	ErrEmptySerialNo = errors.New("empty serial number provided")

	// ErrEmptyToken indicates that the token is empty.
	ErrEmptyToken = errors.New("empty token provided")

	// ErrEmptyList indicates that entity data is empty.
	ErrEmptyList = errors.New("empty list provided")

	// ErrMissingEntityID indicates missing entity ID.
	ErrMissingEntityID = errors.New("missing entity ID")

	// ErrUnsupportedContentType indicates unacceptable or lack of Content-Type.
	ErrUnsupportedContentType = errors.New("unsupported content type")

	// ErrValidation indicates that an error was returned by the API.
	ErrValidation = errors.New("something went wrong with the request")

	// ErrInvalidQueryParams indicates invalid query parameters.
	ErrInvalidQueryParams = errors.New("invalid query parameters")

	// ErrInvalidRequest indicates that the request is invalid.
	ErrInvalidRequest = errors.New("invalid request")

	// ErrMissingCN indicates missing common name.
	ErrMissingCN = errors.New("missing common name")

	// ErrMissingCSR indicates missing csr.
	ErrMissingCSR = errors.New("missing CSR")

	// ErrMissingPrivKey indicates missing csr.
	ErrMissingPrivKey = errors.New("missing private key")
)

Functions

func EncodeError

func EncodeError(_ context.Context, err error, w http.ResponseWriter)

EncodeError encodes an error response.

func EncodeResponse

func EncodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

EncodeResponse encodes successful response.

func MakeHandler

func MakeHandler(svc certs.Service, logger *slog.Logger, instanceID string) http.Handler

MakeHandler returns a HTTP handler for API endpoints.

Types

type IssueFromCSRReq

type IssueFromCSRReq struct {
	CSR string `json:"csr"`
	// contains filtered or unexported fields
}

type Response

type Response interface {
	// Code returns HTTP response code.
	Code() int

	// Headers returns map of HTTP headers with their values.
	Headers() map[string]string

	// Empty indicates if HTTP response has content.
	Empty() bool
}

Response contains HTTP response specific methods.

Jump to

Keyboard shortcuts

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