Skip to content

Instantly share code, notes, and snippets.

@tocalai
Last active July 31, 2019 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tocalai/08d66e77c25065ed3be0a21d313b75af to your computer and use it in GitHub Desktop.
Save tocalai/08d66e77c25065ed3be0a21d313b75af to your computer and use it in GitHub Desktop.
Setup centralize route from Startup.cs
public void ConfigureServices (IServiceCollection services)
{
// model that mapping to appsettings.json
services.Configure<ConfigModel> (Configuration);
// ....
services.AddMvc (options =>
{
// assume that we want our api all prefix route with APIBaseInfo.BasePath=DEV_API_V1 for development phrase.
// we also could switch appsettings to Qas/Release that prefix route with different path:
// QAS_API_V1/RELEASE_API_V1
options.UseCentralRoutePrefix (new RouteAttribute ($"{Configuration.Get<ConfigModel>().APIBaseInfo.BasePath}/"));
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment