added pkgs
This commit is contained in:
parent
1dce375512
commit
de82c22e77
5 changed files with 79 additions and 0 deletions
25
pkg/responses/httpResponse.go
Normal file
25
pkg/responses/httpResponse.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package responses
|
||||
|
||||
type DefaultErrorResponse struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
|
||||
type BadRequest struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
|
||||
type NotFound struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
|
||||
type Unauthorized struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
|
||||
type Forbidden struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
|
||||
type InternalServerError struct {
|
||||
Error string `json:"error" example:"error"`
|
||||
}
|
||||
11
pkg/utils/cpus.go
Normal file
11
pkg/utils/cpus.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package utils
|
||||
|
||||
import "runtime"
|
||||
|
||||
type cpuUtil interface {
|
||||
NumCPU() int
|
||||
}
|
||||
|
||||
func (h *Handler) NumCPU() int {
|
||||
return runtime.NumCPU()
|
||||
}
|
||||
8
pkg/utils/handler.go
Normal file
8
pkg/utils/handler.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package utils
|
||||
|
||||
type Handler struct {
|
||||
}
|
||||
|
||||
func New() *Handler {
|
||||
return &Handler{}
|
||||
}
|
||||
6
pkg/utils/interface.go
Normal file
6
pkg/utils/interface.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package utils
|
||||
|
||||
type Utils interface {
|
||||
timeUtil
|
||||
cpuUtil
|
||||
}
|
||||
29
pkg/utils/time.go
Normal file
29
pkg/utils/time.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type timeUtil interface {
|
||||
TimeNowUTC() time.Time
|
||||
DeletedNullTime() sql.NullTime
|
||||
NullTimeNowUTC() sql.NullTime
|
||||
NullTimeFromNow(time.Time) sql.NullTime
|
||||
}
|
||||
|
||||
func (h *Handler) TimeNowUTC() time.Time {
|
||||
return time.Now().UTC()
|
||||
}
|
||||
|
||||
func (h *Handler) DeletedNullTime() sql.NullTime {
|
||||
return sql.NullTime{Time: time.Time{}, Valid: false}
|
||||
}
|
||||
|
||||
func (h *Handler) NullTimeNowUTC() sql.NullTime {
|
||||
return sql.NullTime{Time: h.TimeNowUTC(), Valid: true}
|
||||
}
|
||||
|
||||
func (h *Handler) NullTimeFromNow(time.Time) sql.NullTime {
|
||||
return sql.NullTime{Time: h.TimeNowUTC(), Valid: true}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue