From aa2220da1a8686f03ed8ad755fab2c7e5d2c020a Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 11 Sep 2019 16:01:22 +0200 Subject: [PATCH] Improves readme --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++----- server/src/main.rs | 8 +++----- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c2eb0450..dd48d2f6 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,52 @@ +Rudf +==== + +[![Build Status](https://travis-ci.org/Tpt/rudf.svg?branch=master)](https://travis-ci.org/Tpt/rudf) +[![dependency status](https://deps.rs/repo/github/Tpt/rudf/status.svg)](https://deps.rs/repo/github/Tpt/rudf) + + Rudf is a work in progress graph database implementing the [SPARQL](https://www.w3.org/TR/sparql11-overview/) standard. There is no released version yet. -Its goal is to provide a compliant, safe and fast graph database. +Its goal is to provide a compliant, safe and fast graph database based on the [RocksDB](https://rocksdb.org/) key-value store. It is written in Rust. -The `lib` directory contains the database written as a Rust library. +The `lib` directory contains the database written as a Rust library and the `server` directory a stand-alone binary of a web server implementing the [SPARQL 1.1 Protocol](https://www.w3.org/TR/sparql11-protocol/). + +Are currently implemented: +* [SPARQL 1.0 Query](https://www.w3.org/TR/rdf-sparql-query/) except `FROM` and `FROM NAMED`. +* [Turtle](https://www.w3.org/TR/turtle/), [TriG](https://www.w3.org/TR/trig/), [N-Triples](https://www.w3.org/TR/n-triples/), [N-Quads](https://www.w3.org/TR/n-quads/) and [RDF XML](https://www.w3.org/TR/rdf-syntax-grammar/) RDF serialization formats for both data ingestion and retrieval using the [Rio library](https://github.com/Tpt/rio). +* [SPARQL Query Results XML Format](http://www.w3.org/TR/rdf-sparql-XMLres/) and [SPARQL Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/). + +## Run the web server + +### Build +You need to have [a recent stable version of Rust and Cargo installed](https://www.rust-lang.org/tools/install). + +If it's done, executing `cargo build --release` in the root directory of this repository should compile the full server after having downloaded its dependencies. +It will create a fat binary in `target/release/rudf_server`. + +### Usage + +Run `./rudf_server` to start the server. It listen by default on `localhost:7878`. + +The server provides an HTML UI with a form to execute SPARQL requests. + +It provides the following routes: +* `/` allows to `POST` data to the server. + For example `curl -f -X POST -H 'Content-Type:application/n-triples' --data-binary "@MY_FILE.nt" http://localhost:7878/` + will add the N-Triples file MY_FILE.nt to the server repository. [Turtle](https://www.w3.org/TR/turtle/), [TriG](https://www.w3.org/TR/trig/), [N-Triples](https://www.w3.org/TR/n-triples/), [N-Quads](https://www.w3.org/TR/n-quads/) and [RDF XML](https://www.w3.org/TR/rdf-syntax-grammar/) are supported. +* `/query` allows to evaluate SPARQL queries against the server repository following the [SPARQL 1.1 Protocol](https://www.w3.org/TR/sparql11-protocol/#query-operation). + For example `curl -f -X POST -H 'Content-Type:application/sparql-query' --data 'SELECT * WHERE { ?s ?p ?o } LIMIT 10' http://localhost:7878/query`. + This route supports content negotiation and could return [Turtle](https://www.w3.org/TR/turtle/), [N-Triples](https://www.w3.org/TR/n-triples/), [RDF XML](https://www.w3.org/TR/rdf-syntax-grammar/), [SPARQL Query Results XML Format](http://www.w3.org/TR/rdf-sparql-XMLres/) and [SPARQL Query Results JSON Format](https://www.w3.org/TR/sparql11-results-json/). + + +Use `rudf_server --help` to see the possible options when starting the server. -[![Build Status](https://travis-ci.org/Tpt/rudf.svg?branch=master)](https://travis-ci.org/Tpt/rudf) -[![dependency status](https://deps.rs/repo/github/Tpt/rudf/status.svg)](https://deps.rs/repo/github/Tpt/rudf) -# License +## License This project is licensed under either of diff --git a/server/src/main.rs b/server/src/main.rs index 52311c24..239417e9 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -24,13 +24,14 @@ pub fn main() { .short("b") .long("bind") .help("Specify a server socket to bind using the format $(HOST):$(PORT)") + .default_value("127.0.0.1:7878") .takes_value(true), ) .arg( Arg::with_name("file") .long("file") .short("f") - .help("File in which persist the dataset") + .help("Directory in which persist the data. By default data are kept in memory.") .takes_value(true), ) .get_matches(); @@ -47,10 +48,7 @@ fn main_with_dataset(repository: Arc, matches: &Arg where for<'a> &'a R: Repository, { - let addr = matches - .value_of("bind") - .unwrap_or("127.0.0.1:7878") - .to_owned(); + let addr = matches.value_of("bind").unwrap().to_owned(); println!("Listening for requests at http://{}", &addr); start_server(addr.to_string(), move |request| {