cfssl: github.com/cloudflare/cfssl/api Index | Files | Directories

package api

import "github.com/cloudflare/cfssl/api"

Package api implements an HTTP-based API and server for CFSSL.

Index

Package Files

api.go

func HandleError Uses

func HandleError(w http.ResponseWriter, err error) (code int)

HandleError is the centralised error handling and reporting.

func ProcessRequestFirstMatchOf Uses

func ProcessRequestFirstMatchOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error)

ProcessRequestFirstMatchOf reads a JSON blob for the request and returns the first match of a set of keywords. For example, a request might have one of the following combinations: (foo=1, bar=2), (foo=1), and (bar=2) By giving a specific ordering of those combinations, we could decide how to accept the request.

func ProcessRequestOneOf Uses

func ProcessRequestOneOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error)

ProcessRequestOneOf reads a JSON blob for the request and makes sure it contains one of a set of keywords. For example, a request might have the ('foo' && 'bar') keys, OR it might have the 'baz' key. In either case, we want to accept the request; however, if none of these sets shows up, the request is a bad request, and it should be returned.

func SendResponse Uses

func SendResponse(w http.ResponseWriter, result interface{}) error

SendResponse builds a response from the result, sets the JSON header, and writes to the http.ResponseWriter.

func SendResponseWithMessage Uses

func SendResponseWithMessage(w http.ResponseWriter, result interface{}, message string, code int) error

SendResponseWithMessage builds a response from the result and the provided message, sets the JSON header, and writes to the http.ResponseWriter.

type HTTPHandler Uses

type HTTPHandler struct {
    Handler          // CFSSL handler
    Methods []string // The associated HTTP methods
}

HTTPHandler is a wrapper that encapsulates Handler interface as http.Handler. HTTPHandler also enforces that the Handler only responds to requests with registered HTTP methods.

func (HTTPHandler) ServeHTTP Uses

func (h HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP encapsulates the call to underlying Handler to handle the request and return the response with proper HTTP status code

type Handler Uses

type Handler interface {
    Handle(w http.ResponseWriter, r *http.Request) error
}

Handler is an interface providing a generic mechanism for handling HTTP requests.

type HandlerFunc Uses

type HandlerFunc func(http.ResponseWriter, *http.Request) error

HandlerFunc is similar to the http.HandlerFunc type; it serves as an adapter allowing the use of ordinary functions as Handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler object that calls f.

func (HandlerFunc) Handle Uses

func (f HandlerFunc) Handle(w http.ResponseWriter, r *http.Request) error

Handle calls f(w, r)

type Response Uses

type Response struct {
    Success  bool              `json:"success"`
    Result   interface{}       `json:"result"`
    Errors   []ResponseMessage `json:"errors"`
    Messages []ResponseMessage `json:"messages"`
}

Response implements the CloudFlare standard for API responses.

func NewErrorResponse Uses

func NewErrorResponse(message string, code int) Response

NewErrorResponse is a shortcut for creating an error response for a single error.

func NewSuccessResponse Uses

func NewSuccessResponse(result interface{}) Response

NewSuccessResponse is a shortcut for creating new successful API responses.

func NewSuccessResponseWithMessage Uses

func NewSuccessResponseWithMessage(result interface{}, message string, code int) Response

NewSuccessResponseWithMessage is a shortcut for creating new successul API responses that includes a message.

type ResponseMessage Uses

type ResponseMessage struct {
    Code    int    `json:"code"`
    Message string `json:"message"`
}

ResponseMessage implements the standard for response errors and messages. A message has a code and a string message.

Directories

PathSynopsis
bundlePackage bundle implements the HTTP handler for the bundle command.
certadd
certinfoPackage certinfo implements the HTTP handler for the certinfo command.
clientPackage client implements a Go client for CFSSL API commands.
crlPackage crl implements the HTTP handler for the crl command.
gencrlPackage gencrl implements the HTTP handler for the gencrl commands.
generatorPackage generator implements the HTTP handlers for certificate generation.
health
infoPackage info implements the HTTP handler for the info command.
initcaPackage initca implements the HTTP handler for the CA initialization command
ocspPackage ocsp implements the HTTP handler for the ocsp commands.
revokePackage revoke implements the HTTP handler for the revoke command
scan
signPackage sign implements the HTTP handler for the certificate signing command.
signhandlerPackage signhandler provides the handlers for signers.

Package api imports 5 packages (graph) and is imported by 793 packages. Updated 2020-11-15. Refresh now. Tools for package owners.