mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 09:48:08 -04:00

* style: fix formatting in .air.toml and installation.mdx * feat: add --strip-base-prefix flag to modify request paths when forwarding Closes: #638 * refactor: apply structpacking (betteralign) * fix: add validation for strip-base-prefix and base-prefix configuration * fix: improve request path handling by cloning request and modifying URL path * chore: remove integration tests as they are too annoying to debug on my system
38 lines
784 B
Go
38 lines
784 B
Go
package challenge
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
var (
|
|
ErrFailed = errors.New("challenge: user failed challenge")
|
|
ErrMissingField = errors.New("challenge: missing field")
|
|
ErrInvalidFormat = errors.New("challenge: field has invalid format")
|
|
)
|
|
|
|
func NewError(verb, publicReason string, privateReason error) *Error {
|
|
return &Error{
|
|
Verb: verb,
|
|
PublicReason: publicReason,
|
|
PrivateReason: privateReason,
|
|
StatusCode: http.StatusForbidden,
|
|
}
|
|
}
|
|
|
|
type Error struct {
|
|
PrivateReason error
|
|
Verb string
|
|
PublicReason string
|
|
StatusCode int
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
return fmt.Sprintf("challenge: error when processing challenge: %s: %v", e.Verb, e.PrivateReason)
|
|
}
|
|
|
|
func (e *Error) Unwrap() error {
|
|
return e.PrivateReason
|
|
}
|