Documentation ¶
Index ¶
- Variables
- func AssertEqualTime(t *testing.T, expected, actual time.Time)
- func DefaultCSRFToken(r *http.Request) string
- func DetermineReturnToURL(request *url.URL, defaultReturnTo *url.URL, whitelistedDomains []url.URL) (string, error)
- func EasyCookieJar(t *testing.T, o *cookiejar.Options) *cookiejar.Jar
- func EasyGet(t *testing.T, c *http.Client, url string) (*http.Response, []byte)
- func EasyGetBody(t *testing.T, c *http.Client, url string) []byte
- func FakeCSRFTokenGenerator(r *http.Request) string
- func FakeCSRFTokenGeneratorWithToken(token string) func(r *http.Request) string
- func IsJSONRequest(r *http.Request) bool
- func IsValidNumber(s string) bool
- func IsZeroUUID(id db.UUID) bool
- func MustEncodeJSON(t *testing.T, in interface{}) string
- func MustReadAll(r io.Reader) []byte
- func NewCSRFHandler(router http.Handler, writer herodot.Writer, logger logrus.FieldLogger, ...) *nosurf.CSRFHandler
- func NewTestCSRFHandler(router http.Handler) *nosurf.CSRFHandler
- func NewTestHTTPRequest(t *testing.T, method, url string, body io.Reader) *http.Request
- func NewUUID() db.UUID
- func ParseUUID(in string) db.UUID
- func RequireEqualTime(t *testing.T, expected, actual time.Time)
- func RequireJSONMarshal(t *testing.T, in interface{}) []byte
- func SessionGetString(r *http.Request, s sessions.Store, id string, key interface{}) (string, error)
- func SessionGetStringOr(r *http.Request, s sessions.Store, id, key, fallback string) string
- func SessionPersistValues(w http.ResponseWriter, r *http.Request, s sessions.Store, id string, ...) error
- func TypeMap(m map[string]string) (map[string]interface{}, error)
- func UntypedMapToJSON(m map[string]string) (json.RawMessage, error)
- type CSRFProvider
- type CSRFToken
- type CSRFTokenGeneratorProvider
- type CookieProvider
- type Ider
- type LoggingProvider
- type RouterAdmin
- type RouterPublic
- type WriterProvider
Constants ¶
This section is empty.
Variables ¶
View Source
var EmptyUUID db.UUID
View Source
var (
ErrInvalidCSRFToken = herodot.ErrForbidden.WithReasonf("A request failed due to a missing or invalid csrf_token value.")
)
Functions ¶
func DefaultCSRFToken ¶
func DetermineReturnToURL ¶
func FakeCSRFTokenGenerator ¶
func IsJSONRequest ¶
func IsValidNumber ¶
IsValidNumber reports whether s is a valid JSON number literal.
Taken from encoding/json
func IsZeroUUID ¶
func MustEncodeJSON ¶
func MustReadAll ¶
func NewCSRFHandler ¶
func NewTestCSRFHandler ¶
func NewTestCSRFHandler(router http.Handler) *nosurf.CSRFHandler
func NewTestHTTPRequest ¶
func RequireJSONMarshal ¶
func SessionGetString ¶
func SessionGetString(r *http.Request, s sessions.Store, id string, key interface{}) (string, error)
SessionGetString returns a string for the given id and key or an error if the session is invalid, the key does not exist, or the key value is not a string.
func SessionGetStringOr ¶
SessionGetStringOr returns a string for the given id and key or the fallback value if the session is invalid, the key does not exist, or the key value is not a string.
func SessionPersistValues ¶
func SessionPersistValues(w http.ResponseWriter, r *http.Request, s sessions.Store, id string, values map[string]interface{}) error
SessionPersistValues adds values to the session store and persists the changes.
func UntypedMapToJSON ¶
func UntypedMapToJSON(m map[string]string) (json.RawMessage, error)
Types ¶
type CSRFProvider ¶
type CSRFProvider interface {
CSRFHandler() *nosurf.CSRFHandler
}
type CookieProvider ¶
type LoggingProvider ¶
type LoggingProvider interface {
Logger() logrus.FieldLogger
}
type RouterAdmin ¶
type RouterAdmin struct {
*httprouter.Router
}
func NewRouterAdmin ¶
func NewRouterAdmin() *RouterAdmin
type RouterPublic ¶
type RouterPublic struct {
*httprouter.Router
}
func NewRouterPublic ¶
func NewRouterPublic() *RouterPublic
type WriterProvider ¶
Click to show internal directories.
Click to hide internal directories.