AndrewBurian / AndrewBurian/powermux
Support handlers with return values
- 主要言語
- Go
- スター
- 20
- フォーク
- 4
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
In order to reduce logic errors, we want the handlers to have the following signatures:
```
func (h *EnabledHandler) Get(rw http.ResponseWriter, req *http.Request) (constants.HTTPStatusCode, interface{})
```
Allow powermux to take these handlers and then allow for configuration of the conversion function
```
...
coreRouter.HandlerConversionFunc(baseHandler.ToHandler)
...
// ToHandler wraps a ResultHandler function into standard http.HandlerFunc
func (h *BaseHandler) ToHandler(rh ResultHandler) func(http.ResponseWriter, *http.Request) {
return func(rw http.ResponseWriter, req *http.Request) {
statusCode, v := rh(rw, req)
h.RenderResult(statusCode, v, rw, req)
}
}
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。