Documentation ¶
Index ¶
- Constants
- type ChocoKacang
- func (gock *ChocoKacang) AuthToken() (token string)
- func (gock *ChocoKacang) BadRequest() Response
- func (gock *ChocoKacang) BindRequestBody(contentType string, v any) (err error)
- func (gock *ChocoKacang) Cookie(name string) (string, error)
- func (gock *ChocoKacang) Header(key string) string
- func (gock *ChocoKacang) JSON(code int, data any) Response
- func (gock *ChocoKacang) MethodNotAllowed() Response
- func (gock *ChocoKacang) Next()
- func (gock *ChocoKacang) NotFound() Response
- func (gock *ChocoKacang) Render(code int, r render.Render) Response
- func (gock *ChocoKacang) RequestMimeType() string
- func (gock *ChocoKacang) Response(code int, data string) Response
- func (gock *ChocoKacang) SetCookie(cookie *http.Cookie)
- func (gock *ChocoKacang) SetHeader(key, value string)
- func (gock *ChocoKacang) Text(code int, format string, v ...any) Response
- type CustomHandler
- type DB
- type Data
- type Database
- type Handler
- type Handlers
- type Param
- type Params
- type Pool
- type Response
- type Route
- type RouteGroup
- type Router
- func (r *Router) Any(path string, handlers ...Handler)
- func (r *Router) Delete(path string, handlers ...Handler)
- func (r *Router) Get(path string, handlers ...Handler)
- func (r *Router) Group(path string, handlers ...Handler) *Router
- func (r *Router) Match(methods []string, path string, handlers ...Handler)
- func (r *Router) Options(path string, handlers ...Handler)
- func (r *Router) Patch(path string, handlers ...Handler)
- func (r *Router) Post(path string, handlers ...Handler)
- func (r *Router) Put(path string, handlers ...Handler)
- func (r *Router) Use(handlers ...Handler) Route
- type Server
- func (srv *Server) Database(name, driver, dsn string)
- func (srv *Server) Handler() http.Handler
- func (srv *Server) Route(method, path string, handlers ...Handler)
- func (srv *Server) Run()
- func (srv *Server) ServeHTTP(rsw http.ResponseWriter, rq *http.Request)
- func (srv *Server) Use(handlers ...Handler) Route
- type Writer
Constants ¶
View Source
const ( Default400Body = "Bad Request" Default403Body = "Forbidden" Default404Body = "Not Found" Default405Body = "Method Not Allowed" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChocoKacang ¶
type ChocoKacang struct { Config config.Config Logger *log.Logger DB *Database Session any Request *http.Request Writer Writer Params Params // contains filtered or unexported fields }
func (*ChocoKacang) AuthToken ¶
func (gock *ChocoKacang) AuthToken() (token string)
func (*ChocoKacang) BindRequestBody ¶
func (gock *ChocoKacang) BindRequestBody(contentType string, v any) (err error)
func (*ChocoKacang) Cookie ¶
func (gock *ChocoKacang) Cookie(name string) (string, error)
Get cookie
func (*ChocoKacang) MethodNotAllowed ¶
func (gock *ChocoKacang) MethodNotAllowed() Response
Return 405 response
func (*ChocoKacang) Next ¶
func (gock *ChocoKacang) Next()
func (*ChocoKacang) RequestMimeType ¶
func (gock *ChocoKacang) RequestMimeType() string
Get request mime type
func (*ChocoKacang) Response ¶
func (gock *ChocoKacang) Response(code int, data string) Response
Return response with requested mime type
func (*ChocoKacang) SetHeader ¶
func (gock *ChocoKacang) SetHeader(key, value string)
Set response header
type CustomHandler ¶
type CustomHandler func(serve *ChocoKacang, data Data) Response
type DB ¶
type DB interface { Exec(query string, args ...any) (sql.Result, error) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) Prepare(query string) (*sql.Stmt, error) PrepareContext(ctx context.Context, query string) (*sql.Stmt, error) Query(query string, args ...any) (*sql.Rows, error) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) QueryRow(query string, args ...any) *sql.Row QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row }
type Handler ¶
type Handler func(serve *ChocoKacang) Response
type RouteGroup ¶
RouteGroup defines all router register functin inclide grouping function
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router help framework to register route path, handlers and middlewares
type Server ¶
type Server struct { Router DB *Database Config config.Config Logger *log.Logger ServerErrorHandler CustomHandler PageNotFoundHandler CustomHandler // contains filtered or unexported fields }
Server is a framework instance contains configuration, router and logger instance. Create an instance of framework, by New()
Source Files ¶
Click to show internal directories.
Click to hide internal directories.