Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
luckymrwang committed Dec 14, 2022
1 parent 9b61c34 commit efeaa6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions web-frame/01-standard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func main() {
}
```

spirit 框架的设计以及 API 均参考了 gin。使用 New() 创建 gee 的实例,使用 GET()方法添加路由,最后使用 Run() 启动 Web 服务。这里的路由,只是静态路由,不支持 /hello/:name 这样的动态路由,动态路由我们将在下一次实现。
spirit 框架的设计以及 API 均参考了 gin。使用 New() 创建 spirit 的实例,使用 GET()方法添加路由,最后使用 Run() 启动 Web 服务。这里的路由,只是静态路由,不支持 /hello/:name 这样的动态路由,动态路由我们将在下一次实现。

## spirit.go

Expand All @@ -165,15 +165,15 @@ import (
"net/http"
)

// HandlerFunc defines the request handler used by gee
// HandlerFunc defines the request handler used by spirit
type HandlerFunc func(http.ResponseWriter, *http.Request)

// Engine implement the interface of ServeHTTP
type Engine struct {
router map[string]HandlerFunc
}

// New is the constructor of gee.Engine
// New is the constructor of spirit.Engine
func New() *Engine {
return &Engine{router: make(map[string]HandlerFunc)}
}
Expand Down Expand Up @@ -226,5 +226,5 @@ curl http://localhost:9999/world
404 NOT FOUND: /world
```

至此,整个Gee框架的原型已经出来了。实现了路由映射表,提供了用户注册静态路由的方法,包装了启动服务的函数。当然,到目前为止,我们还没有实现比 net/http 标准库更强大的能力,不用担心,很快就可以将动态路由、中间件等功能添加上去了。
至此,整个 Spirit 框架的原型已经出来了。实现了路由映射表,提供了用户注册静态路由的方法,包装了启动服务的函数。当然,到目前为止,我们还没有实现比 net/http 标准库更强大的能力,不用担心,很快就可以将动态路由、中间件等功能添加上去了。

0 comments on commit efeaa6a

Please sign in to comment.