RM

package module
v0.0.0-...-4f06caa Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: GPL-3.0 Imports: 2 Imported by: 0

README

RM,超级精简的一个web服务。适用于单独做某一个类型的接口;没有过多代码,全官方库;没有过多技巧。 就仅仅只是,使用map来路由的。你可以直接看实现源码,全官方库,通俗易懂。

OK,使用方法。

安装

go get gitee.com/ruige_fun/RM

来弄个简单的例子:

package main

import (
	"gitee.com/ruige_fun/RM"
	"fmt"
	"net/http"
)

func init() {
	/*路由注册*/
	RM.Router["/user/login"] = login
}
func main() {
	RM.Start("127.0.0.1:8080", "user")
}

func login(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte(fmt.Sprint(r.URL)))
}

值得注意的是,RM.Router["/user/login"] 这个里面的user,必须和 RM.Start("127.0.0.1:8080", "user") 这里面这个user,是一样的。

这个的作用,就是判断请求是否是以

/user 开头的,如果是,则可以继续。如果不是,那么就会直接返回404。

这个RM仅仅适合,开发某个接口而用。不适合独立web一个站。

如果你想自己做一个web站,可以试试增加了日志,静态的RS

https://gitee.com/ruige_fun/RS

https://gitee.com/ruige_fun/RS

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HeaderSet = make(map[string]string)

报文头设置

View Source
var Router = make(map[string]func(w http.ResponseWriter, r *http.Request))

路由器

Functions

func SetHeader

func SetHeader(key string, value string)

func Start

func Start(addr string, urlPrev string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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