Skip to content

Instantly share code, notes, and snippets.

@gistlyn
gistlyn / AppHost.cs
Last active June 30, 2021 07:12
plugins
public class AppHost : AppHostBase
{
public AppHost() : base("Web",typeof(MyServices).Assembly){}
public override void Configure(Container container)
{
// Feature Plugin with default configuration
Plugins.Add(new ValidationFeature());
// Feature Plugin with custom configuration
public class AppHost : AppHostBase
{
public AppHost() : base("Web",typeof(MyServices).Assembly){}
// Configure your AppHost with the necessary configuration
// and dependencies your App needs
public override void Configure(Container container)
{
container.Register<IBar>(new Bar {
Name = "Registered as interface"
@gistlyn
gistlyn / MyServices.cs
Last active June 30, 2021 07:11
native-clients
public class MyServices : Service
{
public object Any(Hello request)
{
return new HelloResponse {
Result = $"Hello, {request.Name}!"
};
}
}
@gistlyn
gistlyn / Hello.vue
Last active June 30, 2021 07:11
web-client
@Component
export class HelloApi extends Vue {
@Prop() public name: string;
public txtName: string = '';
public result: string = '';
public mounted() {
this.nameChanged(this.name);
}
@gistlyn
gistlyn / Client.cs
Last active June 30, 2021 07:11
service-clients
var baseUrl = "https://web.web-templates.io";
var client = new JsonServiceClient(baseUrl);
var response = client.Get(new Hello { Name = "World!" });
@gistlyn
gistlyn / CachedProxy.cs
Last active June 30, 2021 06:45
using-cache
[CacheResponse(Duration = 60 * 60, MaxAge = 30 * 60)]
public class CachedServices : Service
{
public object Get(CachedGetAllCustomers request) =>
Gateway.Send(new GetAllCustomers());
public object Get(CachedGetCustomerDetails request) =>
Gateway.Send(new GetCustomerDetails { Id=request.Id });
public object Get(CachedGetOrders request) =>
@gistlyn
gistlyn / Aws.cs
Last active June 30, 2021 09:21
supported-cache
public class AppHost : AppHostBase
{
public AppHost() : base("Web",typeof(MyServices).Assembly){}
public override void Configure(Container container)
{
var awsDb = new AmazonDynamoDBClient(
Secrets.AWS_ACCESS_KEY,
Secrets.AWS_SECRET_KEY,
RegionEndpoint.USEast1);
@gistlyn
gistlyn / AppHost.cs
Last active June 30, 2021 06:37
setup
public class AppHost : AppHostBase
{
public AppHost() : base("Web",
typeof(MyServices).Assembly) { }
public override void Configure(Container container)
{
container.Register<IRedisClientsManager>(c =>
new RedisManagerPool("localhost:6379"));
@gistlyn
gistlyn / Configure.Cors.cs
Created June 25, 2021 05:52
Configure CORS
using ServiceStack;
namespace MyApp
{
public class ConfigureCors : IConfigureAppHost
{
public void Configure(IAppHost appHost)
{
appHost.Plugins.Add(new CorsFeature());
}
@gistlyn
gistlyn / AppHost.cs
Last active June 24, 2021 10:56
ArchiveServices backend for New Package UI
// License BSD https://github.com/ServiceStack/servicestack-client/blob/master/LICENSE.txt
// Partial AppConfig used by ArchiveServices.cs
public class AppConfig
{
public Dictionary<string, HashSet<string>> TemplateMixMap { get; set; } = new();
}
public class AppHost : AppHostBase
{