Skip to content

Instantly share code, notes, and snippets.

@gistlyn
Last active June 30, 2021 07:11
Show Gist options
  • Save gistlyn/eb430d172b85da35724f4fce40d55d2d to your computer and use it in GitHub Desktop.
Save gistlyn/eb430d172b85da35724f4fce40d55d2d to your computer and use it in GitHub Desktop.
appsettings
public class AppHost : AppHostBase
{
public AppHost() : base("Web",typeof(MyServices).Assembly)
{
var customSettings = new FileInfo("appsettings.txt");
if (customSettings.Exists)
{
AppSettings = new TextFileSettings(customSettings.FullName);
}
}
public override void Configure(Container container)
{
var redisHost = AppSettings.GetString("RedisHost");
if (redisHost != null)
{
container.Register<IServerEvents>(c =>
new RedisServerEvents(new PooledRedisClientManager(redisHost)));
container.Resolve<IServerEvents>().Start();
}
}
}
# Which port to host Chat app on
port 1337
# Change what starting background image should be used
background /img/bg.jpg
# Don't allow Anon Users to use Remote Control
LimitRemoteControlToAuthenticatedUsers False
#default settings for all oauth providers uses AuthTest OAuth configured for http://localhost:1337/
oauth.RedirectUrl http://localhost:1337/
oauth.CallbackUrl http://localhost:1337/auth/{0}
public class ServerEventsServices : Service
{
public IAppSettings AppSettings { get; set; }
public void Any(PostRawToChannel request)
{
if (!IsAuthenticated && AppSettings.Get("LimitRemoteControlToAuthenticatedUsers", false))
throw new HttpError(HttpStatusCode.Forbidden, "You must be authenticated to use remote control.");
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment