2021-05-14 15:19:02 +00:00
|
|
|
package upgrade
|
2018-05-04 06:41:40 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
2018-09-29 12:39:12 +00:00
|
|
|
|
2018-05-04 06:41:40 +00:00
|
|
|
// invalid request
|
|
|
|
// - multiple-value if only 1 expected
|
|
|
|
type InvalidRequest struct {
|
|
|
|
Field string
|
|
|
|
Reason string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err InvalidRequest) Error() string {
|
|
|
|
return fmt.Sprintf("Invalid field '%s': %s", err.Field, err.Reason)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Request misses fields (request-line or headers)
|
|
|
|
type IncompleteRequest struct {
|
|
|
|
MissingField string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (err IncompleteRequest) Error() string {
|
|
|
|
return fmt.Sprintf("imcomplete request, '%s' is invalid or missing", err.MissingField)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Request has a violated origin policy
|
|
|
|
type InvalidOriginPolicy struct {
|
|
|
|
Host string
|
|
|
|
Origin string
|
|
|
|
err error
|
|
|
|
}
|
2018-09-29 12:39:12 +00:00
|
|
|
|
2018-05-04 06:41:40 +00:00
|
|
|
func (err InvalidOriginPolicy) Error() string {
|
|
|
|
return fmt.Sprintf("invalid origin policy; (host: '%s' origin: '%s' error: '%s')", err.Host, err.Origin, err.err)
|
2018-09-29 12:39:12 +00:00
|
|
|
}
|