handlers

package
v0.0.0-...-28e7d11 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(reader io.Reader, res interface{}) error

func EncodeJSON

func EncodeJSON(writer io.Writer, res interface{}) error

Types

type Handlers

type Handlers struct {
	// contains filtered or unexported fields
}

func InitializeHandlers

func InitializeHandlers(database *database.EmployeeDB, log hclog.Logger) *Handlers

func (*Handlers) CreateEmployee

func (h *Handlers) CreateEmployee(rw http.ResponseWriter, r *http.Request)

swagger:route POST /employees create_employee Request to create new employee

responses:

	200: employeeResponse
 422: errorValidation
 501: errorResponse

POST request CreateEmployee

func (*Handlers) DeleteEmployeeByID

func (h *Handlers) DeleteEmployeeByID(rw http.ResponseWriter, r *http.Request)

swagger:route DELETE /api/{id} employees delete_employee Delete the employee details using the id responses:

201: noContentResponse
404: errorResponse

GET request GetEmployeeByID

func (*Handlers) GetAllEmployees

func (h *Handlers) GetAllEmployees(rw http.ResponseWriter, r *http.Request)

swagger:route GET /api employees get_all_employees Return the list of employees details responses:

200: employeeResponse
404: errorResponse

GET request GetAllEmployees

func (*Handlers) GetEmployeeByID

func (h *Handlers) GetEmployeeByID(rw http.ResponseWriter, r *http.Request)

swagger:route GET /api/{id} employees get_employee_by_id Return the employee details for the id responses:

200: employeeResponse
404: errorResponse

GET request GetEmployeeByID

func (*Handlers) ResponseValidator

func (h *Handlers) ResponseValidator(request http.Handler) http.Handler

func (*Handlers) UpdateEmployee

func (h *Handlers) UpdateEmployee(rw http.ResponseWriter, r *http.Request)

swagger:route PUT /api/{id} employees update_employee Return the updated employee details for the id responses:

200: employeeResponse
404: errorResponse

PUT request UpdateEmployee

type KeyEmp

type KeyEmp struct{}

type ServerError

type ServerError struct {
	Error string `json:"error"`
}

The structure containing server error msgs

type ValidationErrorMsg

type ValidationErrorMsg struct {
	Error []string `json:"error"`
}

The structure containing validation error msgs

Jump to

Keyboard shortcuts

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