Skip to content

Simple web framework for the Go programming language

Notifications You must be signed in to change notification settings

pangxieke/simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go实现web服务器

简单实现Go web框架功能。

实现如下功能

  • 自定义路由
  • 中间件
  • 日志

Controller

继承BaseController

type HelloController struct {
	BaseController
}

方法返回error

func (this *HelloController) Hello() (err error) {
	fmt.Println("hello controller, method Hello")
	if true {
		err = fmt.Errorf("this is error")
		return
	}
	return this.SuccessJson("success")
}

Router

路由注入

r := New()

r.addPath("/hello", Action((*controllers.HelloController).Hello))

Log

简单封装log日志

Run

go run cmd/main/main.go

Build

make build

About

Simple web framework for the Go programming language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published