Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct handler, faygo will automatically bind/verify the request parameters and generate the online API doc.

Faygo report card github issues github closed issues GitHub release GoDoc view Go网络编程群

Faygo Favicon

Faygo is a fast and concise Go Web framework that can be used to develop high-performance web app(especially API) with fewer codes. Just define a struct Handler, Faygo will automatically bind/verify the request parameters and generate the online API doc. Go to <User Manual>

简体中文

faygo index

faygo apidoc

faygo server

Latest version

Version

v1.2.0

Requirements

Go Version ≥ 1.8

Quick Start

  • Way 1: download source
go get -u -v github.com/henrylee2cn/faygo
go get -u -v github.com/henrylee2cn/fay
        fay command [arguments]

The commands are:
        new        create, compile and run (monitor changes) a new faygo project
        run        compile and run (monitor changes) an any existing go project

fay new appname [apptpl]
        appname    specifies the path of the new faygo project
        apptpl     optionally, specifies the faygo project template type

fay run [appname]
        appname    optionally, specifies the path of the new project

Features

  • One struct Handler can get more things:
  • Define Handler/Middleware
  • Bind and verify request parameters
  • Generate an online document for the Swagger 2.0 API
  • Database ORM mapping
  • Handler and Middleware are exactly the same, both implement the Handler interface (func or struct), which together constitute the handler chain of the router.
  • Supports multiple network types:
Network types Configuration net_types
HTTP http
HTTPS/HTTP2(TLS) https
HTTPS/HTTP2(Let's Encrypt TLS) letsencrypt
HTTPS/HTTP2(Let's Encrypt TLS on UNIX socket) unix_letsencrypt
HTTP(UNIX socket) unix_http
HTTPS/HTTP2(TLS on UNIX socket) unix_https
  • Support single-service & single-listener, single-service & multi-listener, multi-service & multi-listener and so on. The config of multiple services is independent of each other
  • The high-performance router based on httprouter supports both chain and tree registration styles; supports flexible static file router (such as DirFS, RenderFS, MarkdownFS, etc.)
  • Support graceful shutdown and rebooting, provide fay tools which has new projects, hot compilation , meta programming function
  • Use the most powerful pongo2 as the HTML rendering engine
  • Support near-LRU memory caching (mainly used for static file cache)
  • Support cross-platform color log system, and has two output interface(console and file)
  • Support session management (If you use a persistent storage engine, you must use gob.Register() to register the relevant custom type before starting the service)
  • Support global gzip compression config
  • Support XSRF security filtering
  • Most features try to use simple ini configs to avoid unnecessary recompilation, and these profiles can be automatically assigned default values
  • Provide gorm, xorm, sqlx, directSQL, Websocket, ini, http client and many other commonly used expansion packages

faygo handler multi-usage

Simple example

package main

import (
    // "mime/multipart"
    "time"
    "github.com/henrylee2cn/faygo"
)

type Index struct {
    Id        int      `param:"<in:path> <required> <desc:ID> <range: 0:10>"`
    Title     string   `param:"<in:query> <nonzero>"`
    Paragraph []string `param:"<in:query> <name:p> <len: 1:10> <regexp: ^[\\w]*$>"`
    Cookie    string   `param:"<in:cookie> <name:faygoID>"`
    // Picture         *multipart.FileHeader `param:"<in:formData> <name:pic> <maxmb:30>"`
}

func (i *Index) Serve(ctx *faygo.Context) error {
    if ctx.CookieParam("faygoID") == "" {
        ctx.SetCookie("faygoID", time.Now().String())
    }
    return ctx.JSON(200, i)
}

func main() {
    app := faygo.New("myapp", "0.1")

    // Register the route in a chain style
    app.GET("/index/:id", new(Index))

    // Register the route in a tree style
    // app.Route(
    //     app.NewGET("/index/:id", new(Index)),
    // )

    // Start the service
    faygo.Run()
}

/*
http GET:
    http://localhost:8080/index/1?title=test&p=abc&p=xyz
response:
    {
        "Id": 1,
        "Title": "test",
        "Paragraph": [
            "abc",
            "xyz"
        ],
        "Cookie": "2016-11-13 01:14:40.9038005 +0800 CST"
    }
*/

All samples

Handler and middleware

Handler and middleware are the same, both implemente Handler interface!

  • function type
// Page handler doesn't contains API doc description
func Page() faygo.HandlerFunc {
    return func(ctx *faygo.Context) error {
        return ctx.String(200, "faygo")
    }
}

// Page2 handler contains API doc description
var Page2 = faygo.WrapDoc(Page(), "test page2 notes", "test")
  • struct type
// Param binds and validates the request parameters by Tags
type Param struct {
    Id    int    `param:"<in:path> <required> <desc:ID> <range: 0:10>"`
    Title string `param:"<in:query>"`
}

// Serve implemente Handler interface
func (p *Param) Serve(ctx *faygo.Context) error {
    return ctx.JSON(200,
        faygo.Map{
            "Struct Params":    p,
            "Additional Param": ctx.PathParam("additional"),
        }, true)
}

// Doc implemente API Doc interface (optional)
func (p *Param) Doc() faygo.Doc {
    return faygo.Doc{
        // Add the API notes to the API doc
        Note: "param desc",
        // declare the response content format to the API doc
        Return: faygo.JSONMsg{
            Code: 1,
            Info: "success",
        },
        // additional request parameter declarations to the API doc (optional)
        Params: []faygo.ParamInfo{
            {
                Name:  "additional",
                In:    "path",
                Model: "a",
                Desc:  "defined by the `Doc()` method",
            },
        },
    }
}

Filter function

The filter function must be HandleFunc type!

func Root2Index(ctx *faygo.Context) error {
    // Direct access to `/index` is not allowed
    if ctx.Path() == "/index" {
        ctx.Stop()
        return nil
    }
    if ctx.Path() == "/" {
        ctx.ModifyPath("/index")
    }
    return nil
}

Route registration

  • tree style
// New application object, params: name, version
var app1 = faygo.New("myapp1", "1.0")

// router
app1.Filter(Root2Index).
    Route(
        app1.NewNamedGET("test page", "/page", Page()),
        app1.NewNamedGET("test page2", "/page2", Page2),
        app1.NewGroup("home",
            app1.NewNamedGET("test param", "/param", &Param{
                // sets the default value in the API documentation for the request parameters (optional)
                Id:    1,
                Title: "test param",
            }),
        ),
    )
  • chain style
// New application object, params: name, version
var app2 = faygo.New("myapp2", "1.0")

// router
app2.Filter(Root2Index)
app2.NamedGET("test page", "/page", Page())
app2.NamedGET("test page2", "/page2", Page2)
app2.Group("home")
{
    app2.NamedGET("test param", "/param", &Param{
        // sets the default value in the API documentation for the request parameters(optional)
        Id:    1,
        Title: "test param",
    })
}

Shutdown and reboot

  • shutdown gracefully
kill [pid]
  • reboot gracefully
kill -USR2 [pid]

Configuration

  • Each instance of the application has a single config (file name format config/{appname}[_{version}].ini). Refer to the following:
net_types              = http|https              # List of network type: http | https | unix_http | unix_https | letsencrypt | unix_letsencrypt
addrs                  = 0.0.0.0:80|0.0.0.0:443  # List of multiple listening addresses
tls_certfile           =                         # TLS certificate file path
tls_keyfile            =                         # TLS key file path
letsencrypt_dir        =                         # Let's Encrypt TLS certificate cache directory
unix_filemode          = 0666                    # File permissions for UNIX listener, requires octal number
http_redirect_https    = false                   # Redirect from 'http://hostname:port1' to 'https://hostname:port2'
read_timeout           = 0s                      # Maximum duration for reading the full; ns|µs|ms|s|m|h request (including body)
write_timeout          = 0s                      # Maximum duration for writing the full; ns|µs|ms|s|m|h response (including body)
multipart_maxmemory_mb = 32                      # Maximum size of memory that can be used when receiving uploaded files
slow_response_threshold= 0s                      # When response time > slow_response_threshold, log level   = 'WARNING'; 0 means not limited; ns|µs|ms|s|m|h
print_body             = false                   # Form requests are printed in JSON format, but other types are printed as-is

[router]                                         # Routing config section
redirect_trailing_slash   = true                 # Automatic redirection (for example, `/foo/` -> `/foo`)
redirect_fixed_path       = true                 # Tries to fix the current request path, if no handle is registered for it
handle_method_not_allowed = true                 # Returns 405 if the requested method does not exist, otherwise returns 404
handle_options            = true                 # Automatic response OPTIONS request, you can set the default Handler in Faygo
no_default_params         = false                # If true, don't assign default request parameter values based on initial parameter values of the routing handler
default_upload            = true                 # Automatically register the default router: /upload/*filepath
default_static            = true                 # Automatically register the default router: /static/*filepath

[xsrf]                                           # XSRF security section
enable        = false                            # Whether enabled or not
key           = faygoxsrf                        # Encryption key
expire_second = 3600                             # Expire of XSRF token

[session]                                        # Session section
enable                 = false                   # Whether enabled or not
provider               = memory                  # Data storage
name                   = faygosessionID          # The client stores the name of the cookie
provider_config        =                         # According to the different engine settings different config information
cookie_life_second     = 0                       # The default value is 0, which is the lifetime of the browser
gc_life_second         = 300                     # The interval between triggering the GC
max_life_second        = 3600                    # The session max lefetime
auto_setcookie         = true                    # Automatically set on the session cookie value, the general default true
domain                 =                         # The domain name that is allowed to access this cookie
enable_sid_in_header   = false                   # Whether to write a session ID to the header
name_in_header         = Faygosessionid          # The name of the header when the session ID is written to the header
enable_sid_in_urlquery = false                   # Whether to write the session ID to the URL Query params

[apidoc]                                         # API documentation section
enable      = true                               # Whether enabled or not
path        = /apidoc                            # The URL path
nolimit     = false                              # If true, access is not restricted
real_ip     = false                              # If true, means verifying the real IP of the visitor
whitelist   = 192.*|202.122.246.170              # `whitelist=192.*|202.122.246.170` means: only IP addresses that are prefixed with `192.` or equal to `202.122.246.170` are allowed
desc        =                                    # Description of the application
email       =                                    # Technician's Email
terms_url   =                                    # Terms of service
license     =                                    # The license used by the API
license_url =                                    # The URL of the protocol content page
  • Only one global config is applied (config/__global__.ini). Refer to the following:
[cache]                                          # Cache section
enable         = false                           # Whether enabled or not
size_mb        = 32                              # Max size by MB for file cache, the cache size will be set to 512KB at minimum.
expire_second  = 60                              # Maximum duration for caching

[gzip]                                           # compression section
enable         = false                           # Whether enabled or not
min_length     = 20                              # The minimum length of content to be compressed
compress_level = 1                               # Non-file response Body's compression level is 0-9, but the files' always 9
methods        = GET                             # List of HTTP methods to compress. If not set, only GET requests are compressed.

[log]                                            # Log section
console_enable = true                            # Whether enabled or not console logger
console_level  = debug                           # Console logger level: critical | error | warning | notice | info | debug
file_enable    = true                            # Whether enabled or not file logger
file_level     = debug                           # File logger level: critical | error | warning | notice | info | debug
async_len      = 0                               # The length of asynchronous buffer, 0 means synchronization

Handler struct tags

tag key required value desc
param in only one path (position of param) if required is unsetted, auto set it. e.g. url: "http://www.abc.com/a/{path}"
param in only one query (position of param) e.g. url: "http://www.abc.com/a?b={query}"
param in only one formData (position of param) e.g. "request body: a=123&b={formData}"
param in only one body (position of param) request body can be any content
param in only one header (position of param) request header info
param in only one cookie (position of param) request cookie info, support: *http.Cookie,http.Cookie,string,[]byte
param name no (e.g.id) specify request param`s name
param required no request param is required
param desc no (e.g.id) request param description
param len no (e.g.3:6) length range [a,b] of param's value
param range no (e.g.0:10) numerical range [a,b] of param's value
param nonzero no param`s value can not be zero
param maxmb no (e.g.32) when request Content-Type is multipart/form-data, the max memory for body.(multi-param, whichever is greater)
param regexp no (e.g.^\\w+$) verify the value of the param with a regular expression(param value can not be null)
param err no (e.g.incorrect password format) the custom error for binding or validating

NOTES:

  • the binding object must be a struct pointer
  • in addition to *multipart.FileHeader, the binding struct's field can not be a pointer
  • if the param tag is not exist, anonymous field will be parsed
  • when the param's position(in) is formData and the field's type is *multipart.FileHeader, multipart.FileHeader, []*multipart.FileHeader or []multipart.FileHeader, the param receives file uploaded
  • if param's position(in) is cookie, field's type must be *http.Cookie or http.Cookie
  • param tags in(formData) and in(body) can not exist at the same time
  • there should not be more than one in(body) param tag

Handler struct fields type

base slice special
string []string [][]byte
byte []byte [][]uint8
uint8 []uint8 *multipart.FileHeader (only for formData param)
bool []bool []*multipart.FileHeader (only for formData param)
int []int *http.Cookie (only for net/http's cookie param)
int8 []int8 http.Cookie (only for net/http's cookie param)
int16 []int16 struct (struct type only for body param or as an anonymous field to extend params)
int32 []int32
int64 []int64
uint8 []uint8
uint16 []uint16
uint32 []uint32
uint64 []uint64
float32 []float32
float64 []float64

Expansion package

package summary import path
barcode github.com/henrylee2cn/faygo/ext/barcode
Bit unit conversion github.com/henrylee2cn/faygo/ext/bitconv
gorm(DB ORM) github.com/henrylee2cn/faygo/ext/db/gorm
sqlx(DB ext) github.com/henrylee2cn/faygo/ext/db/sqlx
xorm(DB ORM) github.com/henrylee2cn/faygo/ext/db/xorm
directSQL(Configured SQL engine) github.com/henrylee2cn/faygo/ext/db/directsql
One-time Password github.com/henrylee2cn/faygo/ext/otp
UUID github.com/henrylee2cn/faygo/ext/uuid
Websocket github.com/henrylee2cn/faygo/ext/websocket
ini github.com/henrylee2cn/faygo/ini
cron github.com/henrylee2cn/faygo/ext/cron
task github.com/henrylee2cn/faygo/ext/task
http client github.com/henrylee2cn/faygo/ext/surfer

Know Cases

Product Name Web/App Server Home Page
盯房 App https://www.df-house.com
eTrade App https://fir.im/ejy
OneFor App https://fir.im/eqb
杰运好车 App https://itunes.apple.com/cn/app/%E6%9D%B0%E8%BF%90%E5%A5%BD%E8%BD%A6/id1301132479?mt=8

Note: Sorted in alphabetical order

Business Users

平安科技    Followme
杭州盯房科技有限公司    众联网游    丰利金服

License

Faygo is under Apache v2 License. See the LICENSE file for the full license text

Owner
henrylee2cn
Cease to programing and cease to live.
henrylee2cn
Comments
  • ini 加载遇到特殊字符会出错

    ini 加载遇到特殊字符会出错

    如果配置文件里密码等信息如果包含#就会截断,导致后边的内容无法加载。解决方案是忽略掉行内的特殊字符。

    ext/db/grom/config.go cfg, err = ini.Load(DBCONFIG_FILE)

    //修改为 cfg, err = ini.LoadSources(ini.LoadOptions{ IgnoreInlineComment: true, }, DBCONFIG_FILE)

  • 用了go mod去管理包,但是因为xorm的core已经变更为xorm.io,所以会报以下错误。

    用了go mod去管理包,但是因为xorm的core已经变更为xorm.io,所以会报以下错误。

    go: github.com/go-xorm/[email protected]: parsing go.mod: unexpected module path "xorm.io/core"

    在go mod 中增加了这个的话,会报这个错误

    replace github.com/go-xorm/core v0.6.3 => xorm.io/core v0.6.3

    go: xorm.io/[email protected] used for two different module paths (github.com/go-xorm/core and xorm.io/core)

    目前可以通过修改版本,但是又会引发另外一个错误

    image

    希望作者有空更新下ext里面的db插件

  • faygo 和新版本golang不兼容,go1.10.1

    faygo 和新版本golang不兼容,go1.10.1

    go version go version go1.10.1 darwin/amd64

    [2018/04/23 15:40:46.768] The PID of the current process is 56453
    [2018/04/23 15:40:46.776] [fay] Start build...
    # errors
    compile: version "go1.9" does not match go tool version "go1.10.1"
    # internal/race
    
  • ctx.URL().Scheme is empty

    ctx.URL().Scheme is empty

    ctx.URL() to JSON:

    {
        "Scheme": "",
        "Opaque": "",
        "User": null,
        "Host": "",
        "Path": "/captcha",
        "RawPath": "",
        "ForceQuery": false,
        "RawQuery": "params=asdf",
        "Fragment": ""
    }
    

    Most of them are empty. How to get theirs value?

  • Attribute Code Used from gorilla/securecookie

    Attribute Code Used from gorilla/securecookie

    When fixing an issue, I came across code that is (in some parts) identical to code in the BSD licensed https://github.com/gorilla/securecookie codebase.

    Specifically:

    • https://github.com/henrylee2cn/faygo/blob/master/session/sess_utils.go#L144-L188 is identical to https://github.com/gorilla/securecookie/blob/master/securecookie.go#L315-L351 - save for replacing the error values
    • https://github.com/henrylee2cn/faygo/blob/master/session/sess_utils.go#L125-L140 is identical to https://github.com/gorilla/securecookie/blob/master/securecookie.go#L273-L292 - save for replacing the error values
    • https://github.com/henrylee2cn/faygo/blob/master/session/sess_utils.go#L83-L116 is identical to https://github.com/gorilla/securecookie/blob/master/securecookie.go#L390-L426 - including comments and the short URL.

    I'm not a stickler for licenses, and I don't know whether you are new to open-source (and thus OSS licensing!), but the concern here is that you are:

    • Copying upstream code in part, but not in whole, and thus introducing weaknesses in the process: https://github.com/henrylee2cn/faygo/issues/8
    • Isolating your users from any upstream fixes we make to securecookie
    • Already vendoring some code, but not all, which makes this appear intentional.

    Can you please either:

    1. Import the securecookie library (vendored or otherwise) and, if necessary, wrap the functions for your own API? -or-
    2. Attribute the library correctly in all files where it is used as per https://github.com/gorilla/securecookie/blob/master/LICENSE

    Thanks!

  • Compile Error ?

    Compile Error ?

    $ go version
    go version go1.7.4 windows/amd64
    $ go get -u -v github.com/henrylee2cn/fay
    github.com/henrylee2cn/fay (download)
    github.com/henrylee2cn/faygo (download)
    github.com/henrylee2cn/faygo
    # github.com/henrylee2cn/faygo
    E:\GOPATH\src\github.com\henrylee2cn\faygo\framework.go:258: srv.Shutdown undefined (type *Server has no field or method Shutdown)
    E:\GOPATH\src\github.com\henrylee2cn\faygo\server.go:209: undefined: http.ErrServerClosed
    
  • Bump github.com/gorilla/websocket from 1.4.0 to 1.4.1

    Bump github.com/gorilla/websocket from 1.4.0 to 1.4.1

    Bumps github.com/gorilla/websocket from 1.4.0 to 1.4.1.

    Release notes

    Sourced from github.com/gorilla/websocket's releases.

    v1.4.1

    Notable Changes

    ⚠️ This release fixes a potential denial-of-service (DoS) vector in gorilla/websocket, and we recommend that all users upgrade to this version (v1.4.1) or later

    The vulnerability could allow an attacker to consume excessive amounts of memory on the server by bypassing read limits, and potentially cause the server to go out-of-memory (OOM).

    See the published security advisory for more details.

    Credit to Max Justicz (https://justi.cz/) for discovering and reporting this, as well as providing a robust PoC and review.

    CHANGELOG

    c3e18be Create release-drafter.yml (#538) 5b740c2 Read Limit Fix (#537) 7e9819d fix typos (#532) ae1634f Create CircleCI config.yml (#519) 80c2d40 fix autobahn test suite link (#503) 6a67f44 remove redundant err!=nil check in conn.go Close method (#505) 0ec3d1b Fix typo 856ca61 Add buffer commentary 7c8e298 Add support for go-module 8ab6030 Add JoinMessages 95ba29e Updated autobahn test suite URL 483fb8d Add "in bytes" to sizes in documentation 76e4896 Fix formatting problem in the docs. (#435) a51a35a Improve header parsing code 3130e8d Return write buffer to pool on write error (#427) cdd40f5 Add comprehensive host test (#429)

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

  • jwt中用到的Bearer,在某些ios会报错

    jwt中用到的Bearer,在某些ios会报错

    在某些IOS上,前端访问faygo时,会报SyntaxError DOM Exception 12的错误。 原因是出在jwt中,token的设置带了一个空格。 可以参考 http://www.blogjava.net/laxxx/archive/2015/12/17/428705.html

    问题的重现,可以在网上下载黑雷苹果模拟器,该模拟器带的Safira,刚好可以重现此问题。

    我的解决办法是用/代替空格,或者二者都支持,当然需要修改下jwt.go的代码

    func (mw *FaygoJWTMiddleware) jwtFromHeader(ctx *faygo.Context, key string) (string, error) {
    	authHeader := ctx.HeaderParam(key)
    	if authHeader == "" {
    		return "", ErrEmptyAuthHeader
    	}
    	// faygo.Debug("jwtFromHeader:", authHeader)
    	// ios某些版本,有空格的话,会报SyntaxError DOM Exception 12
    	parts := strings.SplitN(authHeader, " ", 2)
    	if len(parts) == 2 && parts[0] == mw.TokenHeadName {
    		return parts[1], nil
    	}
    	parts = strings.SplitN(authHeader, "/", 2)
    	if !(len(parts) == 2 && parts[0] == mw.TokenHeadName) {
    		return "", ErrInvalidAuthHeader
    	}
    
    	return parts[1], nil
    }
    
  • Redirect 无法post值

    Redirect 无法post值

    《html》
    《body onload="document.forms[0].submit()"》
    《form method="post" action="https://abc.xxx.com/test"》
    	《input type="hidden" name="serviceName" value="PERSONAL_REGISTER"》《/input》
    《/form》
    《/body》
    《/html》
    

    比如现在用ctx.Redirect(....) 重定向到这个页面 但提交后,页面并没有把这些值post过去。

  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

  • Fix Insecure Token Generation

    Fix Insecure Token Generation

    The way IVs, keys and other tokens used for cryptographic purposes are generated by this framework fall-back to an insecure mode of generation:

    e.g. https://github.com/henrylee2cn/faygo/blob/master/utils/rand.go

    • Falling back to math/rand if crypto/rand fails is dangerous: if the system CSPRNG fails, you should consider crashing, restarting or trying again (and serve the user an opaque error where possible). You cannot trust the values of math/rand to be secure for session tokens, CSRF tokens or cryptographic keys because they are deterministic and may be guessed by an attacker.
    • Conforming the generated bytes to a static alphabet introduces bias. Instead, you should just base64 (or base32, or hex) encode the generated bytes if they need to be consumed in a string context.

    I've made a PR here that addresses these issues: https://github.com/henrylee2cn/faygo/pull/7

    Further reading:

    • http://www.2uo.de/myths-about-urandom/
    • https://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/
  • url with trailing slash /index/100/ match route

    url with trailing slash /index/100/ match route "/index/:id" return 301 not 404

    package main
    
    import (
    	"github.com/henrylee2cn/faygo"
    	"time"
    )
    
    type Index struct {
    }
    
    func (i *Index) Serve(ctx *faygo.Context) error {
    	if ctx.CookieParam("faygoID") == "" {
    		ctx.SetCookie("faygoID", time.Now().String())
    	}
    	return ctx.JSON(200, i)
    }
    
    func main() {
    	app := faygo.New("myapp", "0.1")
    	app.GET("/index/:id", new(Index))
    	faygo.Run() //8080
    }
    ```
    $ curl   http://localhost:8080/index/100/
    <a href="/index/100">Moved Permanently</a>.
    
    ```
    package main
    import (
        "fmt"
        "net/http"
    )
    func main() {
        http.HandleFunc("/hello/aa", func (w http.ResponseWriter, r *http.Request) {
            fmt.Fprintf(w, "Welcome to my website!")
        })
       http.ListenAndServe(":80", nil)
    }
    
    ```
    $ curl   http://localhost:8080/index/100/
    404 page not found
    
Dragon 🐲 🐲 🐲 is an enterprise high performance web framework with Go for the feature and comfortable develop.

Dragon start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfortable develop. 中文

Sep 14, 2022
Dragon 🐲 🐲 🐲 is a lightweight high performance web framework with Go for the feature and comfortable develop.

Dragon project new link start dragon ab performance Dragon ?? ?? ?? is a lightweight high performance web framework with Go for the feature and comfor

Sep 6, 2022
Paramex is a library that binds http request parameters to a Go struct annotated with `param`.

paramex Paramex is a library that binds http request parameters to a Go struct annotated with param. Description To extract http parameters (headers,

Oct 31, 2022
Roche is a Code Generator and Web Framework, makes web development super concise with Go, CleanArch
Roche is a Code Generator and Web Framework, makes web development super concise with Go, CleanArch

It is still under development, so please do not use it. We plan to release v.1.0.0 in the summer. roche is a web framework optimized for microservice

Sep 19, 2022
Timeout handler for http request in Gin framework

Middleware to Handle Request Timeout in Gin Installation Installation go get github.com/s-wijaya/gin-timeout Import it in your code: import ( // o

Dec 14, 2021
RPC Framework abstraction layer. Provides foundation of the RonyDesc to generate RPC server/client codes.

RonyKit RonyKit provides the abstraction layer for creating a cluster aware API server. By defining separate components for each task, you are almost

Dec 15, 2022
GoFarm is an Application Development Framework for especially Backend Developer with Golang

What is GoFarm GoFarm is an Application Development Framework for especially Backend Developer with Golang. Our goal is to develop easier, standardize

Dec 9, 2021
A minimal framework to build web apps; with handler chaining, middleware support; and most of all standard library compliant HTTP handlers(i.e. http.HandlerFunc).
A minimal framework to build web apps; with handler chaining, middleware support; and most of all standard library compliant HTTP handlers(i.e. http.HandlerFunc).

WebGo v4.1.3 WebGo is a minimalistic framework for Go to build web applications (server side) with zero 3rd party dependencies. Unlike full-fledged fr

Jan 1, 2023
burn is a web framework written in golang to develop backend / restapi

burn burn rest api framework About: burn is a web framework written in golang to

Dec 27, 2021
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.
Flamingo Framework and Core Library. Flamingo is a go based framework for pluggable web projects. It is used to build scalable and maintainable (web)applications.

Flamingo Framework Flamingo is a web framework based on Go. It is designed to build pluggable and maintainable web projects. It is production ready, f

Jan 5, 2023
The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework.

jin About The jin is a simplified version of the gin web framework that can help you quickly understand the core principles of a web framework. If thi

Jul 14, 2022
hiboot is a high performance web and cli application framework with dependency injection support

Hiboot - web/cli application framework About Hiboot is a cloud native web and cli application framework written in Go. Hiboot is not trying to reinven

Nov 20, 2022
beego is an open-source, high-performance web framework for the Go programming language.
beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 1, 2023
High performance, minimalist Go web framework
High performance, minimalist Go web framework

Supported Go versions As of version 4.0.0, Echo is available as a Go module. Therefore a Go version capable of understanding /vN suffixed imports is r

Jan 2, 2023
Gearbox :gear: is a web framework written in Go with a focus on high performance
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Jan 3, 2023
Gearbox :gear: is a web framework written in Go with a focus on high performance
Gearbox :gear: is a web framework written in Go with a focus on high performance

gearbox ⚙️ is a web framework for building micro services written in Go with a focus on high performance. It's built on fasthttp which is up to 10x fa

Dec 29, 2022
High performance, simple Go web framework

Elton Elton的实现参考了koa以及echo,中间件的调整均为洋葱模型:请求由外至内,响应由内至外。主要特性如下: 处理函数(中间件)均以返回error的形式响应出错,方便使用统一的出错处理中间件将出错统一转换为对应的输出(JSON),并根据出错的类型等生成各类统计分析 成功响应数据直接赋值

Dec 17, 2022
beego is an open-source, high-performance web framework for the Go programming language.
beego is an open-source, high-performance web framework for the Go programming language.

Beego Beego is used for rapid development of enterprise application in Go, including RESTful APIs, web apps and backend services. It is inspired by To

Jan 8, 2023
letgo is an open-source, high-performance web framework for the Go programming language.

high-performance Lightweight web framework for the Go programming language. golang web framework,高可用golang web框架,go语言 web框架 ,go web

Sep 23, 2022