golang http处理程序包装/链接

问题描述 投票:0回答:1

我正在像这样使用golang http处理程序包装

router := mux.NewRouter()

wrapper1(h http.Handle, ip1 string)    
wrapper2(h http.Handler, ip2 string)    
wrapper3(h http.Handler, ip3 string)    
wrapper4(h http.Handler, ip4 string)    
wrapper5(h http.Handler, ip5 string)

router.Handle("/route1", wrapper5(wrapper4(wrapper3(wrapper2(wrapper3, 
    "input1"), "input2"), "input3"), "input4"), "input5")

现在,如果我需要另一个包装,可以将其链接。

我的问题:这种级别的处理程序链接是一种好方法,还是有一种更好/另一种方式来实现处理程序链接?

go handler
1个回答
0
投票

这是一个小库,可以帮助您链接处理程序:Alice

© www.soinside.com 2019 - 2024. All rights reserved.