package api
import "github.com/cloudflare/cfssl/api"
Package api implements an HTTP-based API and server for CFSSL.
Index ¶
- func HandleError(w http.ResponseWriter, err error) (code int)
- func ProcessRequestFirstMatchOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error)
- func ProcessRequestOneOf(r *http.Request, keywordSets [][]string) (map[string]string, []string, error)
- func SendResponse(w http.ResponseWriter, result interface{}) error
- func SendResponseWithMessage(w http.ResponseWriter, result interface{}, message string, code int) error
- type HTTPHandler
- type Handler
- type HandlerFunc
- type Response
- func NewErrorResponse(message string, code int) Response
- func NewSuccessResponse(result interface{}) Response
- func NewSuccessResponseWithMessage(result interface{}, message string, code int) Response
- type ResponseMessage
Functions ¶
func HandleError ¶
func HandleError(w http.ResponseWriter, err error) (code int)
HandleError is the centralised error handling and reporting.
func ProcessRequestFirstMatchOf ¶
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 ¶
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 ¶
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 ¶
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.
Types ¶
type HTTPHandler ¶
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 ¶
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 ¶
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 ¶
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 ¶
func (f HandlerFunc) Handle(w http.ResponseWriter, r *http.Request) error
Handle calls f(w, r)
type Response ¶
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 ¶
NewErrorResponse is a shortcut for creating an error response for a single error.
func NewSuccessResponse ¶
func NewSuccessResponse(result interface{}) Response
NewSuccessResponse is a shortcut for creating new successful API responses.
func NewSuccessResponseWithMessage ¶
NewSuccessResponseWithMessage is a shortcut for creating new successul API responses that includes a message.
type ResponseMessage ¶
ResponseMessage implements the standard for response errors and messages. A message has a code and a string message.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
api/bundle | Package bundle implements the HTTP handler for the bundle command. |
api/certadd | |
api/certinfo | Package certinfo implements the HTTP handler for the certinfo command. |
api/client | Package client implements a Go client for CFSSL API commands. |
api/crl | Package crl implements the HTTP handler for the crl command. |
api/gencrl | Package gencrl implements the HTTP handler for the gencrl commands. |
api/generator | Package generator implements the HTTP handlers for certificate generation. |
api/health | |
api/info | Package info implements the HTTP handler for the info command. |
api/initca | Package initca implements the HTTP handler for the CA initialization command |
api/ocsp | Package ocsp implements the HTTP handler for the ocsp commands. |
api/revoke | Package revoke implements the HTTP handler for the revoke command |
api/scan | |
api/sign | Package sign implements the HTTP handler for the certificate signing command. |
api/signhandler | Package signhandler provides the handlers for signers. |
- Version
- v1.6.5 (latest)
- Published
- Mar 5, 2024
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 6 days ago –
Tools for package owners.