Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
ErrNotFound corresponds to error response when resource not found
Functions ¶
func CalculateHandler ¶
func CalculateHandler(w http.ResponseWriter, r *http.Request)
func ErrInvalidRequest ¶
ErrInvalidRequest returns an Invalid Request Error Response
Types ¶
type APIExchangeRateResponse ¶
type APIExchangeRateResponse struct { Meta MetaResponse `json:"meta"` Response ExchangeRateResponse }
ExchangeRateResponse represents the information coming from Exchange API
type ErrResponse ¶
type ErrResponse struct { Err error `json:"-"` // low-level runtime error HTTPStatusCode int `json:"-"` // http response status code StatusText string `json:"status"` // user-level status message AppCode int64 `json:"code,omitempty"` // application-specific error code ErrorText string `json:"error,omitempty"` // application-level error message, for debugging }
ErrResponse renderer type for handling all sorts of errors.
In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error
Render sets the status code to request when and error happen
type ExchangeRateResponse ¶
type ExchangeRateResponse struct { Rates map[string]float64 `json:"rates"` Base string `json:"base"` Date string `json:"date"` }
ExchangeRateResponse represents the information coming from Exchange API
type MetaResponse ¶
type ResponseCalculateJSON ¶
type ResponseCalculateJSON struct { AnnualSalary float64 `json:"annual_salary"` MonthlySalary float64 `json:"monthly_salary"` ConvertedSalary float64 `json:"converted_salary"` CalculatedSalary float64 `json:"calculated_salary"` }
ResponseCalculateJSON is the response of the method calculate