myhttp

package
v0.0.0-...-9a81921 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAuthHeader = errors.New("authorization header is empty")

Functions

func UnmarshalRequestBody

func UnmarshalRequestBody(req *http.Request, v interface{}) error

func WriteResponseTo

func WriteResponseTo(rw http.ResponseWriter, r Response) error

Types

type ErrorCode

type ErrorCode int
const (
	UnknownError ErrorCode = iota
	AccessDenied
	InvalidRequest
	InternalServerError
	InvalidPassword
	InvalidCredentials
	MethodNotAllowed
	PasswordStrengthError
	TooManyAttempts
	Unauthorized
	UserExists
	UsernameExists
)

func (ErrorCode) MarshalJSON

func (e ErrorCode) MarshalJSON() ([]byte, error)

func (*ErrorCode) UnmarshalJSON

func (e *ErrorCode) UnmarshalJSON(b []byte) error

type ErrorResponse

type ErrorResponse struct {
	Error            ErrorCode `json:"error,omitempty"`
	ErrorDescription string    `json:"error_description,omitempty"`
	ErrorUri         string    `json:"error_uri,omitempty"`
}

func AccessDeniedErrorResponse

func AccessDeniedErrorResponse() *ErrorResponse

func InternalServerErrorResponse

func InternalServerErrorResponse(err string) *ErrorResponse

func InvalidCredentialsErrorResponse

func InvalidCredentialsErrorResponse() *ErrorResponse

func InvalidPasswordResponse

func InvalidPasswordResponse() *ErrorResponse

func InvalidRequestErrorResponse

func InvalidRequestErrorResponse(err string) *ErrorResponse

func MethodNotAllowedResponse

func MethodNotAllowedResponse(method string) *ErrorResponse

func PasswordStrengthErrorResponse

func PasswordStrengthErrorResponse(err string) *ErrorResponse

func TooManyAttemptsResponse

func TooManyAttemptsResponse() *ErrorResponse

func UnauthorizedErrorResponse

func UnauthorizedErrorResponse(err string) *ErrorResponse

func UserExistsResponse

func UserExistsResponse() *ErrorResponse

func UsernameExistsResponse

func UsernameExistsResponse() *ErrorResponse

func (*ErrorResponse) StatusHTTP

func (r *ErrorResponse) StatusHTTP() int

type Response

type Response interface {
	StatusHTTP() int
}

type ValidateBasicAuthHeaderOutput

type ValidateBasicAuthHeaderOutput struct {
	Login    string
	Password string
}

func ValidateBasicAuthHeader

func ValidateBasicAuthHeader(
	req *http.Request,
) (*ValidateBasicAuthHeaderOutput, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL