calculate

package
v0.0.0-...-c77a84f Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func ErrInvalidRequest(err error) render.Renderer

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 MetaResponse struct {
	Code       int    `json:"code"`
	Disclaimer string `json:"disclaimer"`
}

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

Jump to

Keyboard shortcuts

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