Documentation
¶
Index ¶
- func DecodeJSON(reader io.Reader, res interface{}) error
- func EncodeJSON(writer io.Writer, res interface{}) error
- type Handlers
- func (h *Handlers) CreateEmployee(rw http.ResponseWriter, r *http.Request)
- func (h *Handlers) DeleteEmployeeByID(rw http.ResponseWriter, r *http.Request)
- func (h *Handlers) GetAllEmployees(rw http.ResponseWriter, r *http.Request)
- func (h *Handlers) GetEmployeeByID(rw http.ResponseWriter, r *http.Request)
- func (h *Handlers) ResponseValidator(request http.Handler) http.Handler
- func (h *Handlers) UpdateEmployee(rw http.ResponseWriter, r *http.Request)
- type KeyEmp
- type ServerError
- type ValidationErrorMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
func EncodeJSON ¶
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 (*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 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