OpenRIAServices / OpenRiaServices

The Open RIA Services project continues what was previously known as WCF RIA Services.
https://openriaservices.gitbook.io/openriaservices/
Apache License 2.0
54 stars 47 forks source link

RFC AspNetCore: Simple Urls #507

Closed Daniel-Svensson closed 3 weeks ago

Daniel-Svensson commented 1 month ago

The current Uri schema of "NAMESPACE-TYPENAME.csv/binary/MethodName" is quite long/verbose and can be simplified.

Some of the current issues are that

Proposed Solution

1. Manual service paths

A: Allow specifying paths at startup configration

var app = builder.Build();
app.MapOpenRiaServices("Services",  builder =>
{
    // MyDomainService becomes availible at "Services/My-CustomPath/MethodName" and "Services/MyDomainService/binary"
    builder.AddDomainService<MyDomainService>("My-CustomPath");
    builder.AddDomainService<MyDomainService>("MyDomainService/binary");
});

B; Allow specifying name via attributes

similar to now AspNetMvc allows name to be configured for [Route("Name")]

[EnableClientAccess("My-CustomPath)]
public class MyDomainService : DomainService
{ 

This approach means we should/can also

2. New Naming schemes

We add 2 new url naming options

With the following additional variants for backwards compatibility

Configuration

1. Server side

Should we do a "builder" api?


var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenRiaServices(x => 
{
    x.WithUrlSceme(UrlScheme.FullName);

    // Do we want to enable more schemes ? 
    x.WithUrlSceme(UrlScheme.FullName | UrlScheme.WCF );
    x.WithUrlSceme(UrlScheme.FullName ,  UrlScheme.WCF );
});

2. And/or options

class HostingOptions??
{
    public UriScheme UriScheme { get; set: }
}

If so

3. Attribute based

Add an (assembly level) attribute that specify the endpoint scheme.

Attribute name should probably be something like: [Default]DomainService[Endpoint][Route][***]Attribute

Examples:
[assembly: DefaultDomainServiceEndpointPattern(EndpointPattern.Fullname)]
[assembly: DomainServiceEndpointPattern(EndpointPattern.Fullname)]
[assembly: DomainServiceEndpointScheme(EndpointScheme.Fullname)]
[assembly: DomainServiceEndpointRouteScheme(EndpointScheme.Fullname)]
[assembly: DomainServiceRoutePattern(DomainServiceRoutePattern.Fullname)]

Possible enum names

"Prefix:
- Endpoint*
- EndpointRoute*
- DomainServiceRoute(Routing)*
- DomainServiceEndpoint*
- DomainServiceEndpointRoute*

Suffixes:
- "" (None)
- Pattern
- Scheme
- Naming

Examples:
EndpointPattern.WCF
EndpointRoute.WCF
EndpointRoutePattern.WCF
EndpointRouteScheme.WCF
EndpointRouteNaming.WCF

Pros:

Cons:

Questions:

Client Side

1. manual setting on BinaryHttpDomainClientFactory

2. Should we add a setting to the code generation =

If we add a msbuild parameter (or maybe assembly attribute in server project) we can change to code generation to emit the new kind of UrlScheme

1. Manual service paths

Should we allow both A and B ?

Daniel-Svensson commented 1 month ago

For manual setting:

The settings class will probably be called

  1. OpenRiaServices.Hosting.AspNetCore. OpenRiaServicesHostingOptions
  2. or OpenRiaServices.Hosting.AspNetCore. OpenRiaServicesOptions

UriShchem - really need a better name but unknown

Daniel-Svensson commented 1 month ago

fyi: I added a short section about having an assembly level attribute and try to have it affect both the server and client without any other public api changes