Documentation ¶
Index ¶
- Constants
- Variables
- func ArrContains[T string | int | float32](arr []T, val T) bool
- func GenerateQueryComponenFromStruct(model interface{}, skips []string) (string, []interface{}, string)
- func GetDateNowStringWithTimezone() string
- func GetDateTimeNowStringWithFormat(layout string) string
- func GetDateTimeNowStringWithTimezone() string
- func GetStructKey(field reflect.StructField) string
- func GetStructValue(value reflect.Value) interface{}
- func GetTimeNowStringWithTimezone() string
- func GetTimeNowWithTimezone() time.Time
- func InitHandler(router http.Handler) http.Handler
- func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request)
- func PanicHandler(next http.Handler) http.Handler
- func ParseDate(dateStrInput string) (string, error)
- func ParseToDateOnly(date string) string
- func ParseToTimeOnly(t string) string
- func RouteNotFoundHandler(w http.ResponseWriter, r *http.Request)
- func WriteJson(w http.ResponseWriter, data interface{})
- type App
- func (app *App) AddController(ctrl Controller)
- func (app *App) AddControllers(ctrls Controllers)
- func (app *App) AddScheduler(pattern string, handler cron.HandlerFunc)
- func (app *App) DB() database.ISQL
- func (app *App) Init()
- func (app *App) SetVersion(version string)
- func (app *App) Start() error
- func (app *App) Trx() database.Transactions
- func (app *App) WrapScheduler(wrapper cron.Wrapper)
- func (app *App) WrapToApp(wrapper Wrapper)
- type Apps
- type Controller
- type ControllerConfig
- type ControllerImpl
- type Controllers
- type ErrorOption
- type Handler
- type HttpError
- func BadRequest(message, code string) *HttpError
- func Forbidden(message, code string) *HttpError
- func InternalServerError(message, code string) *HttpError
- func MethodNotAllowed(message, code string) *HttpError
- func NewErr(opts ...ErrorOption) *HttpError
- func NotFound(message, code string) *HttpError
- func TooManyRequest(message, code string) *HttpError
- func Unauthorized(message, code string) *HttpError
- func UnprocessableEntity(message, code string) *HttpError
- type Map
- type Options
- type Request
- type Response
- func (resp *Response) Send(w http.ResponseWriter)
- func (resp *Response) SentNotif(ctx contextpkg.Context, err *HttpError, r *http.Request, traceId string)
- func (resp *Response) SetData(data any, isPaginate ...bool) *Response
- func (resp *Response) SetError(err error) *Response
- func (resp *Response) SetHTTPError(err *HttpError) *Response
- func (resp *Response) SetMessage(msg string) *Response
- func (resp *Response) SetStatusCode(statusCode int) *Response
- type Route
- type RouteOption
- type StringMap
- type ValidationError
- type Wrapper
- type WrittenResponseWriter
Constants ¶
View Source
const ( DateFormat = "2006-01-02" TimeFormat = "15:04:05" )
Variables ¶
View Source
var TimezoneLocation *time.Location
Functions ¶
func GetDateNowStringWithTimezone ¶ added in v2.24.0
func GetDateNowStringWithTimezone() string
func GetDateTimeNowStringWithFormat ¶ added in v2.24.0
func GetDateTimeNowStringWithTimezone ¶ added in v2.24.0
func GetDateTimeNowStringWithTimezone() string
func GetStructKey ¶
func GetStructKey(field reflect.StructField) string
func GetStructValue ¶
func GetTimeNowStringWithTimezone ¶ added in v2.24.0
func GetTimeNowStringWithTimezone() string
func GetTimeNowWithTimezone ¶ added in v2.24.0
func MethodNotAllowedHandler ¶
func MethodNotAllowedHandler(w http.ResponseWriter, r *http.Request)
func ParseDate ¶ added in v2.24.0
ParseDate takes a date string and tries to parse it into the standard format "YYYY-MM-DD".
func ParseToDateOnly ¶ added in v2.24.0
func ParseToTimeOnly ¶ added in v2.24.0
func RouteNotFoundHandler ¶
func RouteNotFoundHandler(w http.ResponseWriter, r *http.Request)
func WriteJson ¶
func WriteJson(w http.ResponseWriter, data interface{})
Types ¶
type App ¶
type App struct { Http *chi.Mux *server.Config TotalEndpoints int // contains filtered or unexported fields }
func (*App) AddController ¶
func (app *App) AddController(ctrl Controller)
func (*App) AddControllers ¶ added in v2.19.0
func (app *App) AddControllers(ctrls Controllers)
func (*App) AddScheduler ¶ added in v2.8.1
func (app *App) AddScheduler(pattern string, handler cron.HandlerFunc)
func (*App) SetVersion ¶ added in v2.23.0
func (*App) Trx ¶ added in v2.13.2
func (app *App) Trx() database.Transactions
func (*App) WrapScheduler ¶ added in v2.8.7
type Controller ¶
type Controller interface {
GetConfig() ControllerConfig
}
type ControllerConfig ¶
type ControllerImpl ¶
type ControllerImpl struct { }
type Controllers ¶ added in v2.19.0
type Controllers interface {
Register() []Controller
}
type ErrorOption ¶
type ErrorOption func(*HttpError)
func WithErrorCallerPath ¶ added in v2.9.7
func WithErrorCallerPath(callerPath string) ErrorOption
func WithErrorCode ¶ added in v2.9.6
func WithErrorCode(code string) ErrorOption
func WithErrorData ¶ added in v2.9.6
func WithErrorData(data interface{}) ErrorOption
func WithErrorMessage ¶ added in v2.9.6
func WithErrorMessage(message string) ErrorOption
func WithErrorStatus ¶ added in v2.9.6
func WithErrorStatus(status int) ErrorOption
func WithTraceId ¶ added in v2.25.0
func WithTraceId(traceId string) ErrorOption
type HttpError ¶
type HttpError struct { Message string `json:"message"` Code string `json:"code"` Status int `json:"-"` TraceId string `json:"trace_id"` Data interface{} `json:"data,omitempty"` CallerPath string `json:"caller_path,omitempty"` }
func BadRequest ¶
func InternalServerError ¶
func MethodNotAllowed ¶
func NewErr ¶
func NewErr(opts ...ErrorOption) *HttpError
func TooManyRequest ¶
func Unauthorized ¶
func UnprocessableEntity ¶
func (*HttpError) Write ¶
func (e *HttpError) Write(w http.ResponseWriter)
type Options ¶
type Options func(api *App)
func ReadTimeout ¶
func WithAPITimeout ¶
func WithAppPort ¶
func WithCronJob ¶ added in v2.8.0
func WithNewRelic ¶ added in v2.20.0
func WithNewRelic() Options
func WithTimezone ¶ added in v2.24.0
func WriteTimeout ¶
type Response ¶
type Response struct { Message string `json:"message,omitempty"` Data any `json:"data,omitempty"` Err error `json:"error,omitempty"` TraceId string `json:"trace_id"` InternalError *HttpError `json:"-"` MetaData *database.ResponseMetaData `json:"metadata,omitempty"` // contains filtered or unexported fields }
func NewResponse ¶
func NewResponse() *Response
func (*Response) Send ¶ added in v2.3.9
func (resp *Response) Send(w http.ResponseWriter)
func (*Response) SetHTTPError ¶
func (*Response) SetMessage ¶
func (*Response) SetStatusCode ¶ added in v2.17.5
type Route ¶
type Route struct { Method string Path string Handler Handler Version int Middlewares *[]func(http.Handler) http.Handler }
func (*Route) GetVersionedPath ¶
type RouteOption ¶
type RouteOption func(*Route)
func WithMiddleware ¶
func WithMiddleware(handlers ...func(http.Handler) http.Handler) RouteOption
func WithPath ¶
func WithPath(path string) RouteOption
func WithVersion ¶
func WithVersion(version int) RouteOption
type ValidationError ¶
type ValidationError struct { Field string `json:"field"` Tag string `json:"tag"` Value string `json:"value"` }
func ValidateStruct ¶
func ValidateStruct(data interface{}) []*ValidationError
type WrittenResponseWriter ¶
type WrittenResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*WrittenResponseWriter) WriteHeader ¶
func (w *WrittenResponseWriter) WriteHeader(status int)
func (*WrittenResponseWriter) Written ¶
func (w *WrittenResponseWriter) Written() bool
Click to show internal directories.
Click to hide internal directories.