Documentation ¶
Index ¶
- Constants
- func ContentType(r *http.Request) string
- func DecodeBase64ToString(b64s string) (string, error)
- func FormValue(r *http.Request, key string) (value string, ok bool)
- func IsHTTPSuccess(status int) bool
- func Just(s string) *string
- func Must(err error)
- func SetDateHeader(h http.Header)
- func Trim(sp *string) (trimmed string, ok bool)
- func UrlEq(a, b *url.URL) bool
- func UrlIn(needle *url.URL, haystack []*url.URL) bool
- func UrlInAny(needle *url.URL, haystacks [][]*url.URL) bool
- func WithParam(u *url.URL, key, value string) *url.URL
- type RWLock
- type SigningHTTPWriter
- type StatusHTTPWriter
Constants ¶
const AP_TYPE = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`
The content type for handling or creating ActivityPub requests.
const HTML_TYPE = "text/html"
The content type for HTML. A browser usually sends request with below set as the Accept header.
Variables ¶
This section is empty.
Functions ¶
func ContentType ¶
Return the content type requested (GET) or povided (POST) by request r.
Returns an empty string if content type could not be determined.
func DecodeBase64ToString ¶
func FormValue ¶
Return the form value with given key from request r. The value may not be empty or only contain whitespace characters.
func IsHTTPSuccess ¶
Returns whether status represents a "successful" response, i.e. whether status is in the range [200,299].
func Just ¶
Return a pointer pointing to s. This is useful in cases where we want to fill pointer fields in structs from function results, i.e.
type Container struct { X *string } c := Container{} c.X = Just(fmt.Sprintf("name=%v", name))
func SetDateHeader ¶
Set the Date header on headersr h to the current time in ANSIC format.
func Trim ¶
Return a trimmed version of the contents of sp. ok is true only when pointer sp is not nil and pointing to a string that consists of at least none-whitespace character.
Types ¶
type SigningHTTPWriter ¶
type SigningHTTPWriter struct {
// contains filtered or unexported fields
}
Implements http.ResponseWriter
func NewSigningWriter ¶
func NewSigningWriter() *SigningHTTPWriter
Create a new placeholder HTTP response writer that implements the http.ResponseWriter interface. You can use it to record interactions to an http.ResponseWriter and then "replay" them by applying them to another (real) response writer.
func (*SigningHTTPWriter) ApplyTo ¶
func (pw *SigningHTTPWriter) ApplyTo(w http.ResponseWriter) error
Apply all operations that were done on this placeholder to response writer w.
func (*SigningHTTPWriter) Body ¶
func (pw *SigningHTTPWriter) Body() []byte
Return a copy of the response body.
func (*SigningHTTPWriter) Header ¶
func (pw *SigningHTTPWriter) Header() http.Header
func (*SigningHTTPWriter) WriteHeader ¶
func (pw *SigningHTTPWriter) WriteHeader(status int)
type StatusHTTPWriter ¶
type StatusHTTPWriter struct { // The response writer to which all calls are forwarded. Target http.ResponseWriter // contains filtered or unexported fields }
An http.ResponseWriter that makes it easy to retrieve the status code.
func (*StatusHTTPWriter) Header ¶
func (sw *StatusHTTPWriter) Header() http.Header
func (*StatusHTTPWriter) Status ¶
func (sw *StatusHTTPWriter) Status() int
Return the status last supplied to WriteHeader or http.StatusOK if WriteHeader was not called before.
func (*StatusHTTPWriter) WriteHeader ¶
func (sw *StatusHTTPWriter) WriteHeader(status int)