Documentation ΒΆ
Index ΒΆ
- Constants
- func CompareHash(s, hash string) (bool, error)
- func GenerateJWT(jwtSecretKey ed25519.PrivateKey, mc jwtv5.MapClaims) (string, error)
- func Hash(s string) (string, error)
- func VerifyJWT(jwtSecretKey ed25519.PublicKey, token string, opts ...jwtv5.ParserOption) (jwtv5.MapClaims, error)
- type App
- func (r *App) CaseSensitive(b bool)
- func (r *App) Delete(s string, h func(ctx *RequestCtx))
- func (r *App) Get(s string, h func(ctx *RequestCtx))
- func (r *App) Handler(ctx *fasthttp.RequestCtx)
- func (r *App) Listen(addr string) error
- func (r *App) ListenTLS(addr, certFile, keyFile string) error
- func (r *App) Middleware(h func(ctx *RequestCtx))
- func (r *App) Patch(s string, h func(ctx *RequestCtx))
- func (r *App) Post(s string, h func(ctx *RequestCtx))
- func (r *App) Put(s string, h func(ctx *RequestCtx))
- type Database
- func (d *Database) Close() error
- func (d *Database) Conn() *gorm.DB
- func (d *Database) Delete(i interface{}) error
- func (d *Database) DeleteByQuery(i interface{}, query interface{}, args ...interface{}) error
- func (d *Database) Destroy(i interface{}) error
- func (d *Database) Find(i interface{}) error
- func (d *Database) FindByQuery(i interface{}, query interface{}, args ...interface{}) error
- func (d *Database) FindCond(i, c interface{}) error
- func (d *Database) First(i, c interface{}) error
- func (d *Database) FirstByQuery(i interface{}, query interface{}, args ...interface{}) error
- func (d *Database) Init() error
- func (d *Database) Migrate(i ...interface{}) error
- func (d *Database) Save(i interface{}) error
- type HTTPResponse
- func (e *HTTPResponse) Accepted(message, path string) *HTTPResponse
- func (e *HTTPResponse) BadRequest(message, path string) *HTTPResponse
- func (e *HTTPResponse) Conflict(message, path string) *HTTPResponse
- func (e *HTTPResponse) Created(message, path string) *HTTPResponse
- func (e *HTTPResponse) Forbidden(message, path string) *HTTPResponse
- func (e *HTTPResponse) InternalServerError(message, path string) *HTTPResponse
- func (e *HTTPResponse) NotFound(message, path string) *HTTPResponse
- func (e *HTTPResponse) ToJson() string
- func (e *HTTPResponse) Unauthorized(message, path string) *HTTPResponse
- type RequestCtx
- func (ctx *RequestCtx) Cookie(name string) string
- func (ctx *RequestCtx) Header(key string) string
- func (ctx *RequestCtx) MethodString() string
- func (ctx *RequestCtx) Next()
- func (ctx *RequestCtx) PathString() string
- func (ctx *RequestCtx) Send(s string)
- func (ctx *RequestCtx) SetContentType(contentType string)
- func (ctx *RequestCtx) SetCookie(cookie *fasthttp.Cookie)
- func (ctx *RequestCtx) SetHeader(key, value string)
- func (ctx *RequestCtx) SetStatusCode(statusCode int)
- type Route
Constants ΒΆ
const ( // DefaultSaltLength is the default salt length. DefaultSaltLength = 32 // DefaultHashLength is the default hash length. DefaultHashLength = 64 )
Variables ΒΆ
This section is empty.
Functions ΒΆ
func CompareHash ΒΆ
Compare compares a string and a hash.
func GenerateJWT ΒΆ
Generate generates a JWT token. It takes a jwtSecretKey string and a struct (interface{}) jwtSecretKey must be EdDSA private key and returns a token and an error.
Types ΒΆ
type App ΒΆ
type App struct {
// contains filtered or unexported fields
}
App stores Routes and middlewares
func (*App) CaseSensitive ΒΆ
CaseSensitive sets if the routes should be checked with case sensitivity
func (*App) Delete ΒΆ
func (r *App) Delete(s string, h func(ctx *RequestCtx))
Delete adds DELETE Route.
func (*App) Middleware ΒΆ
func (r *App) Middleware(h func(ctx *RequestCtx))
Middleware adds middleware
type Database ΒΆ
type Database struct {
// contains filtered or unexported fields
}
Database struct
func NewDatabase ΒΆ
NewDatabase creates a new database connection
func (*Database) DeleteByQuery ΒΆ
DeleteByQuery deletes the model by query
func (*Database) FindByQuery ΒΆ
FindByQuery finds the model by query
func (*Database) First ΒΆ
First finds the first model by custom cudition from the same structure (findOne)
func (*Database) FirstByQuery ΒΆ
FirstByQuery finds the first model by query (findOne)
type HTTPResponse ΒΆ
Error represents an http error.
func (*HTTPResponse) Accepted ΒΆ
func (e *HTTPResponse) Accepted(message, path string) *HTTPResponse
Accepted returns a new HTTPResponse with status 202.
func (*HTTPResponse) BadRequest ΒΆ
func (e *HTTPResponse) BadRequest(message, path string) *HTTPResponse
BadRequest returns a new HTTPResponse with status 400.
func (*HTTPResponse) Conflict ΒΆ
func (e *HTTPResponse) Conflict(message, path string) *HTTPResponse
Conflict returns a new HTTPResponse with status 409.
func (*HTTPResponse) Created ΒΆ
func (e *HTTPResponse) Created(message, path string) *HTTPResponse
Created returns a new HTTPResponse with status 201.
func (*HTTPResponse) Forbidden ΒΆ
func (e *HTTPResponse) Forbidden(message, path string) *HTTPResponse
Forbidden returns a new HTTPResponse with status 403.
func (*HTTPResponse) InternalServerError ΒΆ
func (e *HTTPResponse) InternalServerError(message, path string) *HTTPResponse
InternalServerError returns a new HTTPResponse with status 500.
func (*HTTPResponse) NotFound ΒΆ
func (e *HTTPResponse) NotFound(message, path string) *HTTPResponse
NotFound returns a new HTTPResponse with status 404.
func (*HTTPResponse) ToJson ΒΆ
func (e *HTTPResponse) ToJson() string
ToJson returns the HTTPResponse as a JSON string.
func (*HTTPResponse) Unauthorized ΒΆ
func (e *HTTPResponse) Unauthorized(message, path string) *HTTPResponse
Unauthorized returns a new HTTPResponse with status 401.
type RequestCtx ΒΆ
type RequestCtx struct { *fasthttp.RequestCtx Params map[string]string JsonBody map[string]interface{} Nexts []func(ctx *RequestCtx) // contains filtered or unexported fields }
RequestCtx is an extension of fasthttp.RequestCtx
func NewRequestCtx ΒΆ
func NewRequestCtx(ctx *fasthttp.RequestCtx, h []func(ctx *RequestCtx)) *RequestCtx
NewRequestCtx returns a new RequestCtx
func (*RequestCtx) Cookie ΒΆ
func (ctx *RequestCtx) Cookie(name string) string
Cookie returns cookie value by name
func (*RequestCtx) Header ΒΆ
func (ctx *RequestCtx) Header(key string) string
GetHeader returns the request header with key
func (*RequestCtx) MethodString ΒΆ
func (ctx *RequestCtx) MethodString() string
Method returns the request method
func (*RequestCtx) PathString ΒΆ
func (ctx *RequestCtx) PathString() string
Path returns the request path
func (*RequestCtx) SetContentType ΒΆ
func (ctx *RequestCtx) SetContentType(contentType string)
SetContentType sets the response content type
func (*RequestCtx) SetCookie ΒΆ
func (ctx *RequestCtx) SetCookie(cookie *fasthttp.Cookie)
SetCookie sets cookie.
func (*RequestCtx) SetHeader ΒΆ
func (ctx *RequestCtx) SetHeader(key, value string)
SetHeader sets the response header with key, value pair
func (*RequestCtx) SetStatusCode ΒΆ
func (ctx *RequestCtx) SetStatusCode(statusCode int)
SetStatusCode sets the response status code
type Route ΒΆ
type Route struct { Path string ParamIndexes map[string]uint // map[string]uint{"id": 0, "name": 1, ...} Handler func(ctx *RequestCtx) }
Route stores path, param indexes and handler.
func NewRoute ΒΆ
func NewRoute(path string, h func(ctx *RequestCtx)) Route
NewRoute takes a path string and an handler function and returns new Route.