middleware

How do I set a cookie with a (ruby) rack middleware component?

自闭症网瘾萝莉.ら 提交于 2020-07-17 05:41:35
问题 I'm writing a rack middleware component for a rails app that will need to conditionally set cookies. I am currently trying to figure out to set cookies. From googling around it seems like this should work: class RackApp def initialize(app) @app = app end def call(env) @status, @headers, @response = @app.call(env) @response.set_cookie("foo", {:value => "bar", :path => "/", :expires => Time.now+24*60*60}) [@status, @headers, @response] end end which doesn't give errors, but doesn't set a cookie

Redirecting ASP.NET Core 3.1 MVC Web App not working

点点圈 提交于 2020-07-10 10:26:31
问题 I've published a brand new out-of-the-box app in Azure App Service using a F1 (free) App Service Plan. I have the following class to redirect incoming request like www.mywebapp.azurewebsites.net/ to https://mywebapp.azurewebsites.net/ : public class NonWwwRule : IRule { public void ApplyRule(RewriteContext context) { var req = context.HttpContext.Request; var currentHost = req.Host; if (currentHost.Host.StartsWith("www.")) { var newHost = new HostString(currentHost.Host.Substring(4),