1
0
mirror of https://github.com/umputun/reproxy.git synced 2025-06-30 22:13:42 +02:00

pin golangci-lint version to latest available, fix reported errors

This commit is contained in:
Dmitry Verkhoturov
2024-05-09 23:46:41 +02:00
committed by Umputun
parent cbed6ed705
commit 30173d599c
15 changed files with 79 additions and 72 deletions

View File

@ -9,7 +9,6 @@ import (
)
func main() {
// create demo plugin on port 1234 with two methods: HeaderThing and ErrorThing
// both called via RPC from reproxy core with fully formed lib.Request
plugin := lib.Plugin{
@ -18,16 +17,17 @@ func main() {
Methods: []string{"HeaderThing", "ErrorThing"},
}
log.Printf("start demo plugin")
// Do starts the plugin listener and register with reproxy plugin conductor
// Do start the plugin listener and register with reproxy plugin conductor
if err := plugin.Do(context.TODO(), "http://reproxy:8081", new(Handler)); err != nil {
log.Fatal(err)
}
}
// Handler is an example of middleware handler altering headers and stastus
// Handler is an example of middleware handler altering headers and status
type Handler struct{}
// HeaderThing adds key:val header to the response
// nolint:unparam // error response is required by the interface
func (h *Handler) HeaderThing(req lib.Request, res *lib.Response) (err error) {
log.Printf("req: %+v", req)
res.HeadersOut = http.Header{}
@ -39,6 +39,7 @@ func (h *Handler) HeaderThing(req lib.Request, res *lib.Response) (err error) {
}
// ErrorThing returns status 500 on "/fail" url. This terminated processing chain on reproxy side immediately
// nolint:unparam // error response is required by the interface
func (h *Handler) ErrorThing(req lib.Request, res *lib.Response) (err error) {
log.Printf("req: %+v", req)
if req.URL == "/fail" {