httputil

package
v0.0.0-...-62f0cde Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package httputil defines possible errors in HTTP request

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInternalServerError is thrown when there is any internal error occurs
	ErrInternalServerError = errors.New("Internal server error")
	// ErrNotConnected will be thrown when there is not connection with database
	ErrNotConnected = errors.New("Database is not connected")
	// ErrNotFound will be thrown when item is not existed in table
	ErrNotFound = errors.New("Requested item is not found")
	// ErrConfict will be thrown when item is already exists in table
	ErrConfict = errors.New("Item exists")
	// ErrBadParams will be thrown when given request-body or params is not valid
	ErrBadParams = errors.New("Params is invalid")
	// ErrAccessDenied is thrown when request doesn't contain authorization
	ErrAccessDenied = errors.New("Access denied. Authorization is required")
	// ErrUnauthorized is thrown when user access isinvalid
	ErrUnauthorized = errors.New("Access is unauthorized")
)

Functions

func NewError

func NewError(w http.ResponseWriter, status int, err error, args ...interface{})

NewError will return response in JSON

Types

type HTTPError

type HTTPError struct {
	Code    int    `json:"code" example:"400"`
	Message string `json:"message" example:"StatusBadRequest"`
}

HTTPError wraps around net/http

Jump to

Keyboard shortcuts

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