-
Notifications
You must be signed in to change notification settings - Fork 0
/
gorilla_redirect_server.go
57 lines (50 loc) · 1.68 KB
/
gorilla_redirect_server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package servers
import (
"log/slog"
"github.com/gorilla/mux"
"github.com/relvox/iridescence_go/utils"
)
func RouterHandleRedirect(
r *mux.Router,
log *slog.Logger,
method HttpMethod,
url string,
handler func() (string, error),
) {
hFunc := handleFunc[utils.Unit, string]{handler: handler}
unifiedRouteHandler[utils.Unit, string](r, log, method, url, hFunc, redirectResponseWriter)
log.Debug("handle Redirect", slog.String("method", string(method)), slog.String("url", url))
}
func RouterHandleRedirectVars(
r *mux.Router,
log *slog.Logger,
method HttpMethod,
url string,
handler func(vars map[string]string) (string, error),
) {
hFunc := handleFunc[utils.Unit, string]{handlerV: handler}
unifiedRouteHandler[utils.Unit, string](r, log, method, url, hFunc, redirectResponseWriter)
log.Debug("handle Redirect", slog.String("method", string(method)), slog.String("url", url))
}
func RouterHandleRedirectRequest[TIn any](
r *mux.Router,
log *slog.Logger,
method HttpMethod,
url string,
handler func(request TIn) (string, error),
) {
hFunc := handleFunc[TIn, string]{handlerR: handler}
unifiedRouteHandler[TIn, string](r, log, method, url, hFunc, redirectResponseWriter)
log.Debug("handle Redirect", slog.String("method", string(method)), slog.String("url", url))
}
func RouterHandleRedirectRequestVars[TIn any](
r *mux.Router,
log *slog.Logger,
method HttpMethod,
url string,
handler func(request TIn, vars map[string]string) (string, error),
) {
hFunc := handleFunc[TIn, string]{handlerRV: handler}
unifiedRouteHandler[TIn, string](r, log, method, url, hFunc, redirectResponseWriter)
log.Debug("handle Redirect", slog.String("method", string(method)), slog.String("url", url))
}