D2 & Web-Framework

RedX guibufolo+dlang at gmail.com
Wed Jul 3 02:23:59 PDT 2013


On Friday, 15 July 2011 at 01:00:51 UTC, Adam D. Ruppe wrote:
> Let me list some of the newer features in web.d too, added in
> the last couple weeks.
>
> class ApiObject;
>
> These let you expose a more object oriented interface to your
> stuff on the url.
>
> ====
> class User : ApiObject {
>    this(Foo foo, string id) {}
> }
>
> class Foo : ApiProvider {
>    alias User user;
> }
> =====
>
> Now, when the user goes to:
>
> yoursite.com/yourapp/user/username
>
> It instantiates one of those User classes, passing "username"
> as the second argument to the constructor.
>
> Then, you can add methods to your ApiObject and call them with
> additional slashes on the url. Or, you can put in methods
> with the name of an HTTP operation to apply straight to it.
>

is this still working on the latest git (2bfdccc)? I don't seem 
to be able to call anything..

And do public functions really require "export" now or am i just 
declaring them in i wrong way?

class MySite : ApiProvider {

	export string hello(string name){
		return "Welcome " ~ name ~ "!";
	}

	export string foo(){
		return "foo";
	}

	override Document _defaultPage() {
		return 
_getGenericContainer().appendChild(_sitemap()).parentDocument;
	}
};


mixin FancyMain!MySite;


More information about the Digitalmars-d mailing list