Version: v0.0.0-...-7cc0ef5 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2021 License: GPL-3.0 Imports: 14 Imported by: 0




View Source
const AP_TYPE = `application/ld+json; profile="https://www.w3.org/ns/activitystreams"`

The content type for handling or creating ActivityPub requests.

View Source
const HTML_TYPE = "text/html"

The content type for HTML. A browser usually sends request with below set as the Accept header.


This section is empty.


func ContentType

func ContentType(r *http.Request) string

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 DecodeBase64ToString(b64s string) (string, error)

func FormValue

func FormValue(r *http.Request, key string) (value string, ok bool)

Return the form value with given key from request r. The value may not be empty or only contain whitespace characters.

func IsHTTPSuccess

func IsHTTPSuccess(status int) bool

Returns whether status represents a "successful" response, i.e. whether status is in the range [200,299].

func Just

func Just(s string) *string

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 Must

func Must(err error)

Panic with err if it is not nil. If err is nil, Must does nothing.

func SetDateHeader

func SetDateHeader(h http.Header)

Set the Date header on headersr h to the current time in ANSIC format.

func Trim

func Trim(sp *string) (trimmed string, ok bool)

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.

func UrlEq

func UrlEq(a, b *url.URL) bool

Return whether a and b are equal.

func UrlIn

func UrlIn(needle *url.URL, haystack []*url.URL) bool

Return whether haystack contains an URL that we consider equal to needle.

func UrlInAny

func UrlInAny(needle *url.URL, haystacks [][]*url.URL) bool

Return whether any of the slices in haystacks contains an URL that we consider equal to needle.

func WithParam

func WithParam(u *url.URL, key, value string) *url.URL

Return a deep copy of the URL at u with parameters key=value appended.


type RWLock

type RWLock struct {
	// contains filtered or unexported fields

func (*RWLock) Lock

func (l *RWLock) Lock()

Lock for writing.

func (*RWLock) RLock

func (l *RWLock) RLock()

Lock for reading.

func (*RWLock) RUnlock

func (l *RWLock) RUnlock()

Unlock when previously locked for reading.

func (*RWLock) Unlock

func (l *RWLock) Unlock()

Unlock when previously locked for writing.

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) Write

func (pw *SigningHTTPWriter) Write(bs []byte) (int, error)

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) Write

func (sw *StatusHTTPWriter) Write(bs []byte) (int, error)

func (*StatusHTTPWriter) WriteHeader

func (sw *StatusHTTPWriter) WriteHeader(status int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL