Documentation ¶
Index ¶
Constants ¶
View Source
const ( // ContentTypeHeader is the name of the content-type header field ContentTypeHeader = "Content-Type" // ContentTypeJSON is the JSON content-type ContentTypeJSON = "application/json" // ContentTypeText is the text content-type ContentTypeText = "text/plain" // ContentTypeBinary is the binary content type ContentTypeBinary = "application/octet-stream" )
Variables ¶
View Source
var ( // ServerError is an internal server error ServerError = NewError(http.StatusInternalServerError, StatusServerError) // NotFoundError indicates that the requested content was not found NotFoundError = NewError(http.StatusNotFound, StatusNotFound) // BadRequestError indicates that the request is invalid BadRequestError = NewError(http.StatusBadRequest, StatusBadRequest) )
Functions ¶
This section is empty.
Types ¶
type Error ¶ added in v0.1.3
type Error struct {
// contains filtered or unexported fields
}
Error holds additional context associated with the HTTP request
type ResponseWriter ¶ added in v0.1.3
type ResponseWriter struct {
http.ResponseWriter
}
ResponseWriter wraps the http response writer and implements utility functions
func NewResponseWriter ¶ added in v0.1.3
func NewResponseWriter(rw http.ResponseWriter) *ResponseWriter
NewResponseWriter returns a new response writer
func (*ResponseWriter) Write ¶ added in v0.1.3
func (rw *ResponseWriter) Write(status int, bytes []byte, contentType string)
Write writes the response
func (*ResponseWriter) WriteError ¶ added in v0.1.3
func (rw *ResponseWriter) WriteError(err error)
WriteError writes the given error to the response writer
func (*ResponseWriter) WriteText ¶ added in v0.1.3
func (rw *ResponseWriter) WriteText(status int, text string)
WriteText writes the given text to the response writer
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements an HTTP server
func New ¶
func New(url, certFile, keyFile string, handlers ...common.HTTPHandler) *Server
New returns a new HTTP server
type StatusMsg ¶ added in v0.1.3
type StatusMsg = string
StatusMsg is a descriptive message that's returned in the response
const ( // StatusBadRequest indicate that the request was invalid StatusBadRequest StatusMsg = "bad-request" // StatusEmptyContent indicates that no content was provided in the POST StatusEmptyContent StatusMsg = "empty-content" // StatusNotFound indicates that the content for the provided hash was not found StatusNotFound StatusMsg = "not-found" // StatusServerError indicates that the server experienced an unexpected error StatusServerError StatusMsg = "server-error" )
Click to show internal directories.
Click to hide internal directories.