Code Monkey home page Code Monkey logo

hgin's Introduction

hgin

一个模仿 gin 的简易精巧的 web 框架,包含 路由 (路由前缀树)、上下文、路由分组、使用中间件、模板渲染、静态资源服务、全局错误处理 (打印堆栈信息)

使用

未发布

  1. 下载 hgin 包 (pub 分支) 到项目目录下,在 go.mod 引入
require hgin v0.0.0

replace hgin => ./hgin
  1. 使用
func main() {
    r := hgin.Default()
    r.GET("/", func(c *hgin.Context) {
        c.String(http.StatusOK, "Hello hgin")
    })
    r.GET("/panic", func(c *hgin.Context) {
        names := []string{"hgin"}
        c.String(http.StatusOK, names[100])
    })

    v2 := r.Group("/v2")
    {
        v2.GET("/hello/:name", func(c *hgin.Context) {
            c.String(http.StatusOK, "hello %s, you're at %s\n", c.Param("name"), c.Path)
        })
    }

    _ = r.Run(":9999")
}
  1. 访问 http://localhost:9999/

架构

hgin's People

Contributors

weedsx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.