-
Notifications
You must be signed in to change notification settings - Fork 2
/
Startup.cs
82 lines (72 loc) · 1.82 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using JsonLD.Entities;
using JsonLD.Entities.Context;
using Microsoft.Owin;
using Nancy.Rdf.Sample;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Owin;
using Vocab;
[assembly: OwinStartup(typeof(Startup))]
namespace Nancy.Rdf.Sample
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseNancy();
}
}
public class Person
{
public string Id { get; set; }
[JsonProperty("givenName")]
public string Name { get; set; }
public string LastName { get; set; }
public DateTime DateOfBirth { get; set; }
public string Friend { get; set; }
[JsonProperty]
private string Type
{
get
{
return Foaf.Person;
}
}
private static JObject Context
{
get
{
return new JObject(
"givenName".IsProperty(Foaf.givenName),
"lastName".IsProperty(Foaf.lastName),
"dateOfBirth".IsProperty(Schema.birthDate)
);
}
}
}
public class PersonModule : NancyModule
{
public PersonModule()
{
Get("person/{id}", _ =>
{
return new Person
{
Id = "http://api.guru/person/" + _.id,
Name = "John",
LastName = "Doe",
DateOfBirth = new DateTime(1967, 8, 2),
Friend = ("http://api.guru/person/" + _.id + 10)
};
});
}
}
public class ContextPathMapper : Contexts.DefaultContextPathMapper
{
public ContextPathMapper()
{
ServeContextOf<Person>();
}
}
}