gweb

package module
v0.0.0-...-2c2cbac Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

README

gweb

介绍

基于net/http 的简单web应用

软件架构

软件架构说明
MuxRouter 主路由器,实现路由功能。实现了一个http.Handler接口
Context 请求对象上下文,包含响应与请求处理相关的内容

安装教程
package main
import "gitee.com/qqzj0/gweb"
使用说明

example

package main
import (
    "gitee.com/qqzj0/gweb"
    "net/http"
)

func hello(ctx *gweb.Context) {
    ctx.ResponseWriter.Write([]byte("Hello World!"))
}

func main() {
    mr := gweb.NewMuxRouter()
    mr.Get("/hello", hello)
}

参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	http.ResponseWriter
	*http.Request
	StatusCode int
	// contains filtered or unexported fields
}

func (*Context) Get

func (c *Context) Get(key string) interface{}

func (*Context) Next

func (c *Context) Next()

func (*Context) Set

func (c *Context) Set(key string, v interface{})

type HandleFunc

type HandleFunc func(ctx *Context)

type Handler

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

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MuxRouter

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

func NewMuxRouter

func NewMuxRouter() *MuxRouter

func (*MuxRouter) Get

func (mr *MuxRouter) Get(path string, handleFunc HandleFunc)

func (*MuxRouter) Post

func (mr *MuxRouter) Post(path string, handleFunc HandleFunc)

func (*MuxRouter) ServeHTTP

func (mr *MuxRouter) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*MuxRouter) Use

func (mr *MuxRouter) Use(handleFunc HandleFunc)

Jump to

Keyboard shortcuts

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