By the power invested in me by Moose, I can do:
package My::Server;
use RDF::Server;
protocol 'HTTP';
interface 'REST';
semantic 'Atom';
render xml => 'Atom';
render rdf => 'RDF';
Then, to instantiate it, I use the following configuration (as an example):
my $server = My::Server -> new(
default_renderer => 'Atom',
handler => [ service => (
path_prefix => '/',
workspaces => [
{
title => 'Workspace',
collections => [
{
title => 'All of Foo',
path_prefix => 'foo/',
model => {
namespace => 'http://www.example.com/foo/',
class => 'RDFCore'
}
}
]
}
]
} ]
);
This results in the following urls:
- / - an app:service document
- /foo/ - an app:collection document (because there's no path component configured for the app:workspace)
- /foo/$id - an atom:entry document for the RDF resources centered around http://www.example.com/foo/$id.
The handler attribute is supposed to be a code ref that returns the information (so it can be dynamically built with each request if you really want it to be), but the module that defines the Atom semantics overloads the handler attribute's Moose type and allows coercion. This should allow configuration to be from a config file if the right Moose role is included in the server class.
I might make the rendering management configurable instead of part of the module definition. Unlike the protocol, interface, and semantic modules, the renderers don't include code, attributes, or expectations in the server class.
So far, I have passing tests for fetching app:service and app:collection documents and creating, fetching, and adding triples to RDF resources.
One thing I'm doing that might not be quite 'usual' is that I'm treating an RDF model as a collection of RDF resource documents. RDF resource documents are a collection of RDF triples centered around a particular RDF subject. I'm not treating the entire body of knowledge in the model as a single document. That's part of what's in the Atom semantic I'm working with.
Hopefully more next week, including something on CPAN with a lot more documentation than what I have now.
Re:Wonder if this could make a new Catalyst::Engin
jsmith on 2008-02-20T16:12:43
The framework is designed in part to make the data model accessible, so I don't see why I (or someone) couldn't make a Catalyst adaptation.
The RDF::Server stuff is a small part of a larger project that is being built with Catalyst. I'm separating out the RDF::Server framework since it can be standalone.
Re:YAML?
jsmith on 2008-03-01T03:25:16
Something like this?
my $class = RDF::Server -> build_from_config({
interface => 'REST',
protocol => 'HTTP',
semantic => 'Atom',
renderers => {
'rdf' => 'RDF',
'atom' => 'Atom',
'json' => 'JSON'
}
});
my $server = $class -> new( %config );
Passes tests -- it'll be in version 0.02.