Documentation ¶
Index ¶
- func IsInternal(r *http.Request) bool
- func IsProxied(r *http.Request) bool
- func MethodNotAllowedHandler() http.HandlerFunc
- func NotFoundHandler() http.HandlerFunc
- func UnauthorizedHandler() http.HandlerFunc
- type ClientWriter
- func (c *ClientWriter) BytesWritten() uint64
- func (c *ClientWriter) IsHeaderWritten() bool
- func (c *ClientWriter) SetContentType(contentType string)
- func (c *ClientWriter) SetJsonContentType()
- func (c *ClientWriter) SetStatus(status int)
- func (c *ClientWriter) SetXmlContentType()
- func (c *ClientWriter) StatusCode() int
- func (c *ClientWriter) Write(p []byte) (bytes int, err error)
- func (c *ClientWriter) WriteHeader(code int)
- type ContentType
- type Message
- type RateLimiter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInternal ¶
IsInternal returns true if the request is internal.
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler() http.HandlerFunc
MethodNotAllowedHandler returns a handler that returns a 405 response.
func NotFoundHandler ¶
func NotFoundHandler() http.HandlerFunc
NotFoundHandler returns a handler that returns a 404 response.
func UnauthorizedHandler ¶
func UnauthorizedHandler() http.HandlerFunc
UnauthorizedHandler returns a handler that returns a 401 response.
Types ¶
type ClientWriter ¶
type ClientWriter struct { http.ResponseWriter // contains filtered or unexported fields }
ClientWriter is a wrapper around http.ResponseWriter that provides additional information. It is used to capture the status code and the number of bytes written. It also provides a way to determine if the header has been written.
func NewClientWriter ¶
func NewClientWriter(w http.ResponseWriter) *ClientWriter
NewClientWriter creates a new ClientWriter.
func (*ClientWriter) BytesWritten ¶
func (c *ClientWriter) BytesWritten() uint64
BytesWritten returns the number of bytes written.
func (*ClientWriter) IsHeaderWritten ¶
func (c *ClientWriter) IsHeaderWritten() bool
IsHeaderWritten returns true if the header has been written.
func (*ClientWriter) SetContentType ¶
func (c *ClientWriter) SetContentType(contentType string)
func (*ClientWriter) SetJsonContentType ¶
func (c *ClientWriter) SetJsonContentType()
SetJsonContentType sets the content type to JSON.
func (*ClientWriter) SetStatus ¶
func (c *ClientWriter) SetStatus(status int)
SetStatus sets the status code.
func (*ClientWriter) SetXmlContentType ¶
func (c *ClientWriter) SetXmlContentType()
SetXmlContentType sets the content type to XML.
func (*ClientWriter) StatusCode ¶
func (c *ClientWriter) StatusCode() int
StatusCode returns the status code.
func (*ClientWriter) Write ¶
func (c *ClientWriter) Write(p []byte) (bytes int, err error)
Write writes the data to the connection as part of an HTTP reply.
func (*ClientWriter) WriteHeader ¶
func (c *ClientWriter) WriteHeader(code int)
WriteHeader sends an HTTP response header with the provided status code.
type ContentType ¶
type ContentType string
ContentType represents the content type of the request.
const ( // ContentTypeJSON is the JSON content type. This is the default. ContentTypeJSON ContentType = "application/json" // ContentTypeXML is the XML content type. ContentTypeXML ContentType = "application/xml" // ContentTypeHTML is the HTML content type. ContentTypeHTML ContentType = "text/html" // ContentTypeText is the text content type. ContentTypeText ContentType = "text/plain" // ContentTypePng is the png content type. ContentTypePng ContentType = "image/png" )
func (ContentType) IsIn ¶
func (c ContentType) IsIn(contentTypes ...ContentType) bool
IsIn returns true if the ContentType is in the list of content types.
func (ContentType) String ¶
func (c ContentType) String() string
String returns the string representation of the ContentType.
type Message ¶
type Message struct {
Message string `json:"message" xml:"message"`
}
Message represents a message response.
func NewMessage ¶
NewMessage creates a new Message.
type RateLimiter ¶
type RateLimiter interface { // Allow returns true if the request is allowed. Allow(key string) bool }
func NewRateLimiter ¶
func NewRateLimiter() RateLimiter