Skip to content

Commit 7a37726

Browse files
committed
Update MovieRest to latest best practices
1 parent a306d3a commit 7a37726

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+13514
-434
lines changed

src/ServiceStack.MovieRest/Global.asax.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using ServiceStack.Common.Utils;
44
using ServiceStack.OrmLite;
55
using ServiceStack.OrmLite.Sqlite;
6+
using ServiceStack.ServiceInterface.Cors;
67
using ServiceStack.Text;
78
using ServiceStack.WebHost.Endpoints;
89

@@ -24,33 +25,30 @@ public MovieAppHost() : base("ServiceStack REST at the Movies!", typeof(MovieSer
2425
/// <param name="container">The built-in IoC used with ServiceStack.</param>
2526
public override void Configure(Container container)
2627
{
27-
JsConfig.DateHandler = JsonDateHandler.ISO8601;
28+
//JsConfig.DateHandler = JsonDateHandler.ISO8601;
2829

2930
container.Register<IDbConnectionFactory>(c =>
3031
new OrmLiteConnectionFactory(
3132
"~/App_Data/db.sqlite".MapHostAbsolutePath(),
3233
SqliteOrmLiteDialectProvider.Instance));
3334

34-
var resetMovies = container.Resolve<ResetMoviesService>();
35-
resetMovies.Post(null);
35+
//Call existing service
36+
using (var resetMovies = container.Resolve<ResetMoviesService>())
37+
{
38+
resetMovies.Any(null);
39+
}
3640

3741
Routes
3842
.Add<Movie>("/movies")
3943
.Add<Movie>("/movies/{Id}")
4044
.Add<Movies>("/movies")
4145
.Add<Movies>("/movies/genres/{Genre}");
4246

43-
SetConfig(new EndpointHostConfig
44-
{
45-
GlobalResponseHeaders = {
46-
{ "Access-Control-Allow-Origin", "*" },
47-
{ "Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS" },
48-
{ "Access-Control-Allow-Headers", "Content-Type, X-Requested-With" },
49-
},
50-
//EnableFeatures = onlyEnableFeatures,
51-
//DebugMode = true, //Show StackTraces for easier debugging
52-
});
47+
Plugins.Add(new CorsFeature()); //Enable CORS
5348

49+
SetConfig(new EndpointHostConfig {
50+
//DebugMode = true, //Show StackTraces for easier debugging (default auto inferred by Debug/Release builds)
51+
});
5452
}
5553
}
5654

0 commit comments

Comments
 (0)