Last active
July 31, 2019 06:55
-
-
Save tocalai/08d66e77c25065ed3be0a21d313b75af to your computer and use it in GitHub Desktop.
Setup centralize route from Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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