Documentation ¶
Index ¶
- type Context
- func (ctx *Context) Bind(target interface{}) error
- func (ctx *Context) BindJSON(target interface{}) error
- func (ctx *Context) Get(key string) any
- func (ctx *Context) GetFormValue(name string) (string, error)
- func (ctx *Context) GetQueryParam(name string) (string, error)
- func (ctx *Context) GetRouteParam(name string) (string, error)
- func (ctx *Context) Set(key string, value any)
- func (ctx *Context) WriteJSON(statusCode int, j JSON) error
- func (ctx *Context) WriteString(statusCode int, s string) error
- type DBModel
- type DBType
- type Database
- type Handler
- type JSON
- type Middleware
- type MySQLConfig
- type PostgreSQLConfig
- type Proton
- func (p *Proton) DELETE(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) GET(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) HEAD(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) OPTIONS(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) PATCH(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) POST(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) PUT(path string, handler Handler, middlewares ...Middleware)
- func (p *Proton) Start(address string) error
- func (p *Proton) Static(path string, dirPath string)
- func (p *Proton) UseMiddleware(middlewares ...Middleware)
- type SQLiteConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Database *Database // contains filtered or unexported fields }
Context represents the context of an HTTP request.
func (*Context) Bind ¶ added in v0.1.1
Bind binds data automatically from the HTTP request body to the provided target struct by the content type.
func (*Context) BindJSON ¶
BindJSON binds JSON data from the HTTP request body to the provided target struct by decoding it.
func (*Context) GetFormValue ¶
GetFormValue retrieves a form value from the request by name.
func (*Context) GetQueryParam ¶
GetQueryParam retrieves a query parameter from the request URL by name.
func (*Context) GetRouteParam ¶
GetRouteParam retrieves a parameter from the request route by name.
type DBModel ¶
type DBModel struct { ID uint `json:"id" gorm:"primarykey"` CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` }
DBModel defines common fields for database models.
type Database ¶
Database represents a database connection.
func NewMySQLDatabase ¶
func NewMySQLDatabase(cfg MySQLConfig) *Database
NewMySQLDatabase creates a new MySQL database instance based on the provided configuration.
func NewPostgreSQLDatabase ¶
func NewPostgreSQLDatabase(cfg PostgreSQLConfig) *Database
NewPostgreSQLDatabase creates a new PostgreSQL database instance based on the provided configuration.
func NewSQLiteDatabase ¶
func NewSQLiteDatabase(cfg SQLiteConfig) *Database
NewSQLiteDatabase creates a new SQLite database instance based on the provided configuration.
type Middleware ¶
Middleware represents a middleware function for handling HTTP requests.
type MySQLConfig ¶
type MySQLConfig struct { DBHost string DBPort int DBName string DBUsername string DBPassword string }
MySQLConfig represents configuration parameters for MySQL database.
type PostgreSQLConfig ¶
type PostgreSQLConfig struct { DBHost string DBPort int DBName string DBUsername string DBPassword string }
PostgreSQLConfig represents configuration parameters for PostgreSQL database.
type Proton ¶
type Proton struct {
// contains filtered or unexported fields
}
Proton represents an HTTP server.
func NewWithDatabase ¶
NewWithDatabase creates a new instance of Proton with a specified database.
func (*Proton) DELETE ¶
func (p *Proton) DELETE(path string, handler Handler, middlewares ...Middleware)
DELETE registers a DELETE route with the router.
func (*Proton) GET ¶
func (p *Proton) GET(path string, handler Handler, middlewares ...Middleware)
GET registers a GET route with the router.
func (*Proton) HEAD ¶
func (p *Proton) HEAD(path string, handler Handler, middlewares ...Middleware)
HEAD registers a HEAD route with the router.
func (*Proton) OPTIONS ¶
func (p *Proton) OPTIONS(path string, handler Handler, middlewares ...Middleware)
OPTIONS registers an OPTIONS route with the router.
func (*Proton) PATCH ¶
func (p *Proton) PATCH(path string, handler Handler, middlewares ...Middleware)
PATCH registers a PATCH route with the router.
func (*Proton) POST ¶
func (p *Proton) POST(path string, handler Handler, middlewares ...Middleware)
POST registers a POST route with the router.
func (*Proton) PUT ¶
func (p *Proton) PUT(path string, handler Handler, middlewares ...Middleware)
PUT registers a PUT route with the router.
func (*Proton) UseMiddleware ¶
func (p *Proton) UseMiddleware(middlewares ...Middleware)
UseMiddleware adds middlewares to the Proton instance.
type SQLiteConfig ¶
type SQLiteConfig struct {
DBFile string
}
SQLiteConfig represents configuration parameters for SQLite database.