brief_framework

package module
v0.0.0-...-b2d7ade Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

基于gin实现的简单webserver框架

使用前准备工作

首先获取需要导入的包

$ go get github.com/gin-gonic/gin
$ go get github.com/go-redis/redis
$ go get github.com/Unknwon/goconfig
$ go get github.com/robfig/cron

注:如果导入失败,可以尝试执行如下命令 :

$ yum update nss curl libcurl

使用

  1. import
import "brief_framework"
  1. 实现一个函数

Get方法,需要实现GetHandle

type GetHandler func(map[string]string)(interface{})

参数为Query中的参数, 需要返回一个JSON的结构体. 如:

var get_handle plugin.GetHandler = func(m map[string]string) interface{} {
	type JsonHolder struct {
		Id   int    `json:"id"`
		Name string `json:"name"`
	}
	return JsonHolder{Id: 77, Name: "Get_handle"}
}
  1. init中调用AddProcess

第一个参数是相对路径,如:

func init() {
	plugin.AddProcess("/get", sampleGet)
	plugin.AddProcess("/post", samplePost)
}
  1. 启动
func main() {
	brief_framework.Serve()
} 

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve()

Types

This section is empty.

Directories

Path Synopsis
db
log4go
Package log4go provides level-based and highly configurable logging.
Package log4go provides level-based and highly configurable logging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL