Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to specify nested service path #388

Closed
DraconInteractive opened this issue Jul 1, 2023 · 3 comments
Closed

How to specify nested service path #388

DraconInteractive opened this issue Jul 1, 2023 · 3 comments
Labels
question Further information is requested

Comments

@DraconInteractive
Copy link

Hi again :)
I'm trying to implement environment setup so that my server path goes from
http://mydomain.com/service?whatever=1
to
http://mydomain.com/dev/service?whatever=1

The most logical course to do this was (in my head) to change my layout service assignment to add it there.
For example:

static void Main(string[] args)
{
    string env = GetEnvironmentString(); // returns "dev"
    var service = Layout.Create()
        .AddService<MyService>(env + "/service")
        .Add(CorsPolicy.Permissive());
        
    Host.Create()
        .Handler(service)
        .Console()
        .Run();
}

However, querying this with http://mydomain.com/dev/service returns 404, despite my earlier call of just /service working perfectly.

Apologies for what seem like simple questions, I'm trying to debug these as thoroughly as possible before bringing them before you.

Thanks in advance :)

@DraconInteractive DraconInteractive added the question Further information is requested label Jul 1, 2023
@Kaliumhexacyanoferrat
Copy link
Owner

Hi Peter,

no worries - if you need to ask there is either something missing from the documentation or the API is not self explanatory as it should be.

Layouts are intended to be nested one level at a time, so this should work:

static void Main(string[] args)
{
    string envName= GetEnvironmentString(); // returns "dev"

    var env = Layout.Create()
        .AddService<MyService>("service")
        .Add(CorsPolicy.Permissive());

    var root= Layout.Create()
        .Add(envName, env);
        
    Host.Create()
        .Handler(root)
        .Console()
        .Run();
}

For web applications, this is a powerful tool to define the structure of the app - especially when it comes to attach behavior by using concerns (see the according section in the documentation).

I just created the following issues to make this more clear:

Hope this helps.

Cheers
Andreas

@DraconInteractive
Copy link
Author

This makes perfect sense, thank you!

The documentation is very interesting to me. Its very good at explaining certain high level concepts. I think I'm struggling with certain areas of implementation as it assumes knowledge of various industry standard approaches.

My speciality has always been game development, delving into more regular .Net for side projects etc, so I've missed a lot of those standards.

Perhaps an expansion to the templates section with various common implementations with comments to explain structure and reasoning could help?

Regardless, this project has been by far the most useful tool for me to create quick API's for my game projects so I'm keen to see its progress :)

@Kaliumhexacyanoferrat
Copy link
Owner

Yes, I think comments in the templates could be useful, also with links to the documentation.

Created the following issue for this one:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants