Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F140222
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/tesla/middleware/method_override.ex b/lib/tesla/middleware/method_override.ex
index 375b913..066c62b 100644
--- a/lib/tesla/middleware/method_override.ex
+++ b/lib/tesla/middleware/method_override.ex
@@ -1,37 +1,37 @@
defmodule Tesla.Middleware.MethodOverride do
@moduledoc """
Middleware that adds X-Http-Method-Override header with original request
method and sends the request as post.
Useful when there's an issue with sending non-post request.
Available options:
- `:override` - list of http methods that should be overriden,
everything except get and post if not specified
"""
def call(env, next, opts) do
if overridable?(env, opts) do
env
- |> override(opts)
+ |> override
|> Tesla.run(next)
else
env
|> Tesla.run(next)
end
end
- def override(env, opts) do
+ def override(env) do
env
|> Tesla.Middleware.Headers.call([], %{"X-Http-Method-Override" => "#{env.method}"})
|> Map.put(:method, :post)
end
def overridable?(env, opts) do
if opts[:override] do
env.method in opts[:override]
else
not env.method in [:get, :post]
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 3:37 PM (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
55274
Default Alt Text
(1 KB)
Attached To
Mode
R28 tesla
Attached
Detach File
Event Timeline
Log In to Comment