Skip to content

Register routes with OpenRasta using attributes on your handlers, instead of manually via OR configuration

Notifications You must be signed in to change notification settings

benjaminkeeping/OpenRasta.Routing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This dll takes some of the pain away from registering routes in OpenRasta.
It's on Nuget as "OpenRasta.Routing"

So instead of registering routes like this :

  using (OpenRastaConfiguration.Manual)
  {

    ResourceSpace.Has.ResourcesOfType<object>()
      .AtUri("/foo/{id}").Named("view-foo")
      .HandledBy<FooHandler>()
      .AsJsonDataContract()
      .And.AsXmlDataContract();
  }

You can just call :

  using (OpenRastaConfiguration.Manual)
	{
		// Register all handler's routes in given assembly(s), and all model/wire types in given assembly(s)
		Routing.Register(typeof(FooHandler).Assembly, typeof(Foo).Assembly);
	}

And then tag your handlers : 

    public class FooHandler 
    {
        [Get("/foo/{id}")]
        public OperationResult Foo()
        {
            return new OperationResult.OK
            {
                ResponseResource = new Foo()
            };
        }

There are attributes for Get, Post, Put, Patch and Delete

About

Register routes with OpenRasta using attributes on your handlers, instead of manually via OR configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published