Documentation
¶
Overview ¶
router.go
Index ¶
- func Argon2Hash(password string) (string, error)
- func Argon2Verify(password, encodedHash string) (bool, error)
- func Bcrypt(password string, optionalCost ...int) string
- func Blake2b(data string) string
- func Blake2s(data string) string
- func CompareBcrypt(password, hashed string) bool
- func CreateLogFile(fileName string) error
- func FakeData(filename string, count int, format string)
- func FakeDataDB(filename string, count int)
- func Info()
- func LogError(function string, message string)
- func Md5(args ...string) string
- func Sha256(args ...string) string
- func Sha3_256(args ...string) string
- func Sha3_512(args ...string) string
- func Sha512(args ...string) string
- func Version()
- type Context
- func (c *Context) Default404()
- func (c *Context) Default405()
- func (c *Context) Delete() bool
- func (c *Context) File(filepath string)
- func (c *Context) FormArgon2(key string) string
- func (c *Context) FormBcrypt(key string) string
- func (c *Context) FormBool(key string) bool
- func (c *Context) FormData(key string) string
- func (c *Context) FormFile(key string) (multipart.File, *multipart.FileHeader, error)
- func (c *Context) FormFloat(key string) float64
- func (c *Context) FormInt(key string) int
- func (c *Context) FormMD5(key string) string
- func (c *Context) FormSHA256(key string) string
- func (c *Context) FormSHA512(key string) string
- func (c *Context) Get() bool
- func (c *Context) HTML(status int, tmplPath string, data interface{})
- func (c *Context) HTMLString(status int, html_code string)
- func (c *Context) JSON(status int, data interface{})
- func (c *Context) JSONFile(status int, filepath string)
- func (c *Context) JSONPretty(status int, data interface{}, indent ...int)
- func (c *Context) Param(key string) string
- func (c *Context) ParamInt(key string) (int, error)
- func (c *Context) ParamIntDefault(key string, defaultVal int) int
- func (c *Context) Post() bool
- func (c *Context) Put() bool
- func (c *Context) Query(key string) string
- func (c *Context) QueryBool(key string, defaultVal bool) bool
- func (c *Context) QueryFloat(key string, defaultVal float64) float64
- func (c *Context) QueryInt(key string) (int, error)
- func (c *Context) QueryIntDefault(key string, defaulVal int) int
- func (c *Context) Redirect(status int, format string, args ...interface{})
- func (c *Context) String(status int, text string)
- func (c *Context) Stringf(status int, text string, a ...any)
- func (c *Context) Template404(templatePath string, data ...any)
- func (c *Context) Template405(templatePath string, data ...any)
- func (c *Context) UserAgent() string
- func (c *Context) XML(status int, data interface{})
- func (c *Context) XMLFile(status int, filepath string)
- func (c *Context) XMLPretty(status int, data interface{})
- type Database
- func (d *Database) Begin() *sql.Tx
- func (d *Database) Column(name, typ string)
- func (d *Database) Commit(tx *sql.Tx)
- func (d *Database) Delete(table string, criteria map[string]interface{})
- func (d *Database) DropTable(name string)
- func (d *Database) Execute(query string, args ...interface{}) (sql.Result, error)
- func (d *Database) Exists(table string, criteria map[string]interface{}) bool
- func (d *Database) Find(table, column string, value interface{}) []map[string]interface{}
- func (d *Database) FindAll(table string) []map[string]interface{}
- func (d *Database) Insert(table string, data map[string]interface{})
- func (d *Database) NewTable(name string, builder func(*Database))
- func (d *Database) Rollback(tx *sql.Tx)
- func (d *Database) Truncate(table string)
- func (d *Database) Update(table string, updates map[string]interface{}, whereColumn string, ...)
- type Env
- type FakeUser
- type HandlerFunc
- type Router
- type Server
- func (s *Server) Delete(path string, handler HandlerFunc)
- func (s *Server) Get(path string, handler HandlerFunc)
- func (s *Server) Handle(path string, handler HandlerFunc)
- func (s *Server) Post(path string, handler HandlerFunc)
- func (s *Server) Put(path string, handler HandlerFunc)
- func (s *Server) Run(addr ...string) error
- func (s *Server) SetNotFound(handler HandlerFunc)
- func (s *Server) Static(routePath, dir string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Argon2Hash ¶
func Argon2Verify ¶
func CompareBcrypt ¶
func CreateLogFile ¶
func FakeDataDB ¶ added in v1.4.2
FakeDataDB creates/opens a sqlite database file (modernc.org/sqlite) and inserts `count` fake users. filename: path to .db file (e.g. "users.db") count: number of fake users to insert
Types ¶
type Context ¶
Context represents the context of a single HTTP request in the Flint framework. It provides convenient access to the request data, query parameters, form values, HTTP method checks, and response writers for sending various types of responses. By using Context, developers can easily read input from the client, write output, handle JSON, files, HTML templates, and manage redirects or errors in a structured way.
func (*Context) Default404 ¶
func (c *Context) Default404()
func (*Context) Default405 ¶ added in v1.2.0
func (c *Context) Default405()
func (*Context) FormArgon2 ¶ added in v1.2.0
It automatically hashes the data received from the form with Argon2.
func (*Context) FormBcrypt ¶
Automatically hashes the data received from the form with Bcrypt
func (*Context) FormBool ¶ added in v1.4.2
FormBool returns the value of a form field as a boolean. Accepts values like "true", "1", "yes" → true and "false", "0", "no" → false. Defaults to false if invalid.
func (*Context) FormData ¶
FormData returns the value of a form field for the given key. It reads the data from POST or PUT form submissions.
func (*Context) FormFile ¶
FormFile retrieves the uploaded file and its header from a multipart form for the given form key. It returns the file, its header, and an error if the file cannot be found or opened
func (*Context) FormFloat ¶ added in v1.4.2
FormFloat returns the value of a form field as a float64. If the conversion fails, it logs the error and returns 0.0.
func (*Context) FormInt ¶
FormInt returns the value of a form field as an integer for the given key. If the conversion fails, it logs the error and returns 0.
func (*Context) FormSHA256 ¶
Hashes the data received from the form with Sha256 and returns it.
func (*Context) FormSHA512 ¶
Hashes the data received from the form with Sha512 and returns it.
func (*Context) HTMLString ¶ added in v1.3.2
HTMLString writes the given HTML string directly to the response with the specified HTTP status code.
func (*Context) JSON ¶
JSON encodes the given data as JSON and writes it to the response with the specified HTTP status code.
func (*Context) JSONFile ¶ added in v1.3.1
JSONFile serves a JSON file from the given file path with the specified HTTP status code. Returns 404 if the file is not found.
func (*Context) JSONPretty ¶ added in v1.3.1
JSONPretty encodes the given data as pretty-printed JSON and writes it to the response with the specified HTTP status code. Optional indent size can be provided.
func (*Context) ParamIntDefault ¶ added in v1.3.2
func (*Context) QueryFloat ¶ added in v1.1.0
func (*Context) QueryIntDefault ¶ added in v1.1.0
func (*Context) Redirect ¶
Redirect sends an HTTP redirect to the specified URL with the given status code. Commonly used status codes are 302 (Found), 301 (Moved Permanently), and 307/308.
func (*Context) String ¶
String writes a plain string to the response with the specified HTTP status code.
func (*Context) Stringf ¶ added in v1.1.0
Stringf writes a formatted string to the response with the specified HTTP status code.
func (*Context) Template404 ¶
func (*Context) Template405 ¶ added in v1.2.0
func (*Context) UserAgent ¶ added in v1.2.0
UserAgent returns the User-Agent header from the request.
func (*Context) XML ¶ added in v1.3.2
XML serializes the provided Go data structure into XML and writes it as the response. The response Content-Type is set to application/xml. This is typically used for sending dynamic XML generated from structs.
type Database ¶ added in v1.4.2
type Database struct {
// contains filtered or unexported fields
}
type FakeUser ¶
type FakeUser struct { ID int `json:"id"` Username string `json:"username"` Email string `json:"email"` Password string `json:"password"` HashedPwd string `json:"hashed_password"` FullName string `json:"full_name"` Phone string `json:"phone"` Address string `json:"address"` Country string `json:"country"` CreatedAt time.Time `json:"created_at"` }
FakeUser represents a fake user with extended fields.
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, handler HandlerFunc)
Tüm methodlar için
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
basic
command
|
|
basic/useragent
command
|
|
register_app
command
|
|
search
command
|
|
simple_restapi
command
|
|
simple_restapi/users
command
|
|
test
|
|
run_test
command
|