grest

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2019 License: Unlicense Imports: 17 Imported by: 0

README

grest

a GO lang REST & web framework.

install

go get github.com/dereking/grest

go install github.com/dereking/grest/grest

start a new project

usage:

  grest SUBCMD ARGS

e.g.create a new GREST project in $GOPATH:

   grest new projectName

The project will be created at $GOPATH/src/ProjectName

static files

The directory named "static" is the place which storages the static files. The subdirectories "css", "js", "images", "fonts", "public" storage the corresponding static files.;

controller

there are one Filter Function in controller.

  • OnExecuting Function

websocket

func (c *WsController) Chat(ws *websocket.Conn) {

	defer ws.Close()

	var err error
	var str string

	for { 
		str = "hello, I'm server."

		if err = websocket.Message.Send(ws, str); err != nil {
			break
		} else {
			time.Sleep(time.Second * 2)
		}
	}
}

template Function

  • html 输出html代码. 对字符串进行html关键词\标签转义.
  • fileSize 输出方便阅读的文件大小字符串。
  • datetime 输出日期时间,2017-3-19 00:08:20格式.
  • add 数字加1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrestServer

type GrestServer struct {
	// contains filtered or unexported fields
}

func NewGrestServer

func NewGrestServer(confName string) *GrestServer

func (*GrestServer) AddController

func (s *GrestServer) AddController(name string, ctlType reflect.Type)

func (*GrestServer) Serve

func (s *GrestServer) Serve()

func (*GrestServer) ServeHTTPDispatch

func (s *GrestServer) ServeHTTPDispatch(w http.ResponseWriter, r *http.Request)

http 请求入口, 根据类型派发到ws和http.

Directories

Path Synopsis
cmd
---------------------------------------------- this go file is generated by staticZip.
---------------------------------------------- this go file is generated by staticZip.

Jump to

Keyboard shortcuts

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