mirror of
https://github.com/kataras/iris.git
synced 2025-12-17 09:57:01 +00:00
update core deps
This commit is contained in:
13
cache/client/client.go
vendored
13
cache/client/client.go
vendored
@@ -16,9 +16,7 @@ import (
|
||||
// for each of the cached route paths's response
|
||||
// register one client handler per route.
|
||||
//
|
||||
// it's just calls a remote cache service server/handler,
|
||||
//
|
||||
// which lives on other, external machine.
|
||||
// it's just calls a remote cache service server/handler, which may lives on other, external machine.
|
||||
type ClientHandler struct {
|
||||
// bodyHandler the original route's handler
|
||||
bodyHandler context.Handler
|
||||
@@ -81,11 +79,6 @@ func (h *ClientHandler) AddRule(r rule.Rule) *ClientHandler {
|
||||
// this client is an exported to give you a freedom of change its Transport, Timeout and so on(in case of ssl)
|
||||
var Client = &http.Client{Timeout: cfg.RequestCacheTimeout}
|
||||
|
||||
const (
|
||||
methodGet = "GET"
|
||||
methodPost = "POST"
|
||||
)
|
||||
|
||||
// ServeHTTP , or remote cache client whatever you like, it's the client-side function of the ServeHTTP
|
||||
// sends a request to the server-side remote cache Service and sends the cached response to the frontend client
|
||||
// it is used only when you achieved something like horizontal scaling (separate machines)
|
||||
@@ -113,7 +106,7 @@ func (h *ClientHandler) ServeHTTP(ctx *context.Context) {
|
||||
uri.ServerAddr(h.remoteHandlerURL).ClientURI(ctx.Request().URL.RequestURI()).ClientMethod(ctx.Request().Method)
|
||||
|
||||
// set the full url here because below we have other issues, probably net/http bugs
|
||||
request, err := http.NewRequest(methodGet, uri.String(), nil)
|
||||
request, err := http.NewRequest(http.MethodGet, uri.String(), nil)
|
||||
if err != nil {
|
||||
//// println("error when requesting to the remote service: " + err.Error())
|
||||
// somehing very bad happens, just execute the user's handler and return
|
||||
@@ -145,7 +138,7 @@ func (h *ClientHandler) ServeHTTP(ctx *context.Context) {
|
||||
uri.Lifetime(h.life)
|
||||
uri.ContentType(recorder.Header().Get(cfg.ContentTypeHeader))
|
||||
|
||||
request, err = http.NewRequest(methodPost, uri.String(), bytes.NewBuffer(body)) // yes new buffer every time
|
||||
request, err = http.NewRequest(http.MethodPost, uri.String(), bytes.NewBuffer(body)) // yes new buffer every time
|
||||
|
||||
// println("POST Do to the remote cache service with the url: " + request.URL.String())
|
||||
if err != nil {
|
||||
|
||||
2
cache/client/handler.go
vendored
2
cache/client/handler.go
vendored
@@ -31,7 +31,7 @@ type Handler struct {
|
||||
|
||||
type MaxAgeFunc func(*context.Context) time.Duration
|
||||
|
||||
// NewHandler returns a new cached handler for the "bodyHandler"
|
||||
// NewHandler returns a new Server-side cached handler for the "bodyHandler"
|
||||
// which expires every "expiration".
|
||||
func NewHandler(maxAgeFunc MaxAgeFunc) *Handler {
|
||||
return &Handler{
|
||||
|
||||
Reference in New Issue
Block a user