Documentation ¶
Overview ¶
Package api implements an HTTP-based API and server for CFSSL.
Index ¶
- 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
- type ResponseMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 successul 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.
Directories ¶
Path | Synopsis |
---|---|
Package bundle implements the HTTP handler for the bundle command.
|
Package bundle implements the HTTP handler for the bundle command. |
Package certinfo implements the HTTP handler for the certinfo command.
|
Package certinfo implements the HTTP handler for the certinfo command. |
Package client implements the a Go client for CFSSL API commands.
|
Package client implements the a Go client for CFSSL API commands. |
Package crl implements the HTTP handler for the crl commands.
|
Package crl implements the HTTP handler for the crl commands. |
Package generator implements the HTTP handlers for certificate generation.
|
Package generator implements the HTTP handlers for certificate generation. |
Package info implements the HTTP handler for the info command.
|
Package info implements the HTTP handler for the info command. |
Package initca implements the HTTP handler for the CA initialization command
|
Package initca implements the HTTP handler for the CA initialization command |
Package ocsp implements the HTTP handler for the ocsp commands.
|
Package ocsp implements the HTTP handler for the ocsp commands. |
Package revoke implements the HTTP handler for the revoke command
|
Package revoke implements the HTTP handler for the revoke command |
Package sign implements the HTTP handler for the certificate signing command.
|
Package sign implements the HTTP handler for the certificate signing command. |
Package signhandler provides the handlers for signers.
|
Package signhandler provides the handlers for signers. |