Skip to content

Commit a02eef6

Browse files
committed
Updated docs to take into account recent TLS and library name changes.
1 parent af1824a commit a02eef6

File tree

8 files changed

+35
-23
lines changed

8 files changed

+35
-23
lines changed

README.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ Libraries for exposing your PostgreSQL database as a REST API.
44

55
## Libraries
66

7-
- [`postgres-rest-actix`](postgres-rest-actix/)
8-
7+
- [`postgres-rest-actix`](postgres-rest-actix/)
98
Use `actix-web` to serve a REST API for your PostgreSQL database.
109

11-
- [`postgres-rest`](postgres-rest/)
12-
10+
- [`postgres-rest`](postgres-rest/)
1311
Contains the functions necessary to turn a PostgreSQL database into a REST API. Used by `postgres-rest-actix`.

postgres-rest-actix/README.md

+18-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Use `actix-web` to serve a REST API for your PostgreSQL database.
44

55
```rust
66
use actix_web::{App, HttpServer};
7-
use rust_postgres_rest_actix::{Config};
7+
use postgres_rest_actix::{Config};
8+
use tokio_postgres::NoTls;
89

910
fn main() {
1011
let ip_address = "127.0.0.1:3000";
@@ -13,7 +14,7 @@ fn main() {
1314
HttpServer::new(move || {
1415
App::new().service(
1516
// appends an actix-web Scope under the "/api" endpoint to app.
16-
Config::new("postgresql://[email protected]:5432/postgres")
17+
Config::new("postgresql://[email protected]:5432/postgres", NoTls)
1718
.generate_scope("/api"),
1819
)
1920
})
@@ -112,7 +113,17 @@ Will return the following JSON:
112113

113114
#### Alias (`AS`) syntax is supported too
114115

115-
Changing the previous API endpoint to `/api/child?columns=id,name,parent_id.name as parent_name,parent_id.company_id.name as parent_company_name` or `/api/child?columns=id,name,parent_id.name parent_name,parent_id.company_id.name parent_company_name` will return the aliased fields instead:
116+
Change the previous API endpoint:
117+
118+
**Before:**
119+
`/api/child?columns=id,name,parent_id.name,parent_id.company_id.name`
120+
121+
**After:**
122+
`/api/child?columns=id,name,parent_id.name as parent_name,parent_id.company_id.name as parent_company_name`
123+
or
124+
`/api/child?columns=id,name,parent_id.name parent_name,parent_id.company_id.name parent_company_name`
125+
126+
Now, the response will return the aliased fields instead:
116127

117128
```json
118129
[
@@ -137,7 +148,10 @@ Changing the previous API endpoint to `/api/child?columns=id,name,parent_id.name
137148
The `Config` struct contains the configuration options used by this library.
138149

139150
```rust
140-
let config = Config::new("postgresql://[email protected]:5432/postgres");
151+
use postgres_rest_actix::Config;
152+
use tokio_postgres::NoTls;
153+
154+
let config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
141155
let scope = config.generate_scope("/api");
142156
```
143157

postgres-rest-actix/src/endpoints/query_params_from_request.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::Error;
22
use actix_web::HttpRequest;
33
use rayon::prelude::*;
4-
use rust_postgres_rest::queries::{DeleteParams, InsertParams, SelectParams, UpdateParams};
4+
use postgres_rest::queries::{DeleteParams, InsertParams, SelectParams, UpdateParams};
55
use serde::Deserialize;
66
use serde_json::{Map, Value};
77

postgres-rest-actix/src/endpoints/table.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::query_params_from_request::{
2020
RequestQueryStringParams,
2121
};
2222
use crate::{Config, Error};
23-
use rust_postgres_rest::queries;
23+
use postgres_rest::queries;
2424

2525
/// Deletes table rows and optionally returns the column data in the deleted rows.
2626
pub fn delete_table<T>(

postgres-rest-actix/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use actix_web::{http, HttpResponse};
22
use failure::Fail;
3-
use rust_postgres_rest::Error as RestError;
3+
use postgres_rest::Error as RestError;
44
use serde::Serialize;
55

66
#[derive(Debug, Fail, Serialize)]

postgres-rest-actix/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//!
1212
//! ```no_run
1313
//! use actix_web::{App, HttpServer};
14-
//! use rust_postgres_rest_actix::{Config};
14+
//! use postgres_rest_actix::{Config};
1515
//! use tokio_postgres::tls::NoTls;
1616
//! # use std::thread;
1717
//!
@@ -46,7 +46,7 @@
4646
///
4747
/// ```no_run
4848
/// use actix_web::{App, HttpServer, web};
49-
/// use rust_postgres_rest_actix::{Config, endpoints};
49+
/// use postgres_rest_actix::{Config, endpoints};
5050
/// use tokio_postgres::tls::NoTls;
5151
///
5252
/// fn main() {
@@ -87,7 +87,7 @@ use endpoints::{
8787
};
8888

8989
pub use error::Error;
90-
use rust_postgres_rest::Config as InnerConfig;
90+
use postgres_rest::Config as InnerConfig;
9191

9292
use actix_web::{web, Scope};
9393
use futures::future::Future;
@@ -98,7 +98,7 @@ use tokio_postgres::{
9898

9999
/// Configures and creates the REST API `Scope`.
100100
/// ```no_run
101-
/// use rust_postgres_rest_actix::Config;
101+
/// use postgres_rest_actix::Config;
102102
/// use tokio_postgres::NoTls;
103103
///
104104
/// let config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
@@ -129,7 +129,7 @@ where
129129
{
130130
/// Creates a Config object with default values. `db_url` must be [Postgres-formatted](https://www.postgresql.org/docs/current/libpq-connect.html#id-1.7.3.8.3.6).
131131
/// ```
132-
/// use rust_postgres_rest_actix::Config;
132+
/// use postgres_rest_actix::Config;
133133
/// use tokio_postgres::NoTls;
134134
///
135135
/// let config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
@@ -157,7 +157,7 @@ where
157157
/// ```no_run
158158
/// use futures::future::{Future, ok};
159159
/// use futures::stream::Stream;
160-
/// use rust_postgres_rest_actix::Config;
160+
/// use postgres_rest_actix::Config;
161161
/// use tokio_postgres::NoTls;
162162
///
163163
/// actix::run(|| Config::new("postgresql://[email protected]:5432/postgres", NoTls).connect()
@@ -187,7 +187,7 @@ where
187187

188188
/// Creates the Actix scope url at `scope_name`, which contains all of the other API endpoints.
189189
/// ```no_run
190-
/// use rust_postgres_rest_actix::Config;
190+
/// use postgres_rest_actix::Config;
191191
/// use tokio_postgres::NoTls;
192192
///
193193
/// let config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
@@ -225,7 +225,7 @@ where
225225
/// Set the timer to automatically reset the table stats cache on a recurring interval. If this
226226
/// is not set, the cache is never reset after server start.
227227
/// ```
228-
/// use rust_postgres_rest_actix::Config;
228+
/// use postgres_rest_actix::Config;
229229
/// use tokio_postgres::NoTls;
230230
///
231231
/// let mut config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);

postgres-rest-actix/tests/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use actix::spawn as actix_spawn;
22
use actix_web::{test::block_fn, App, HttpServer};
33
use futures::{stream::Stream, Future};
4-
use rust_postgres_rest_actix::Config;
4+
use postgres_rest_actix::Config;
55
use std::{fs::read_to_string, thread::spawn as thread_spawn};
66
use tokio_postgres::{connect, NoTls};
77

postgres-rest/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ where
4141
impl<T: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static> Config<T> {
4242
/// Creates a new Config.
4343
/// ```
44-
/// use rust_postgres_rest::Config;
44+
/// use postgres_rest::Config;
4545
/// use tokio_postgres::tls::NoTls;
4646
///
4747
/// let mut config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
@@ -71,7 +71,7 @@ impl<T: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static> Config<T> {
7171
/// ```no_run
7272
/// use futures::future::{Future, ok};
7373
/// use futures::stream::Stream;
74-
/// use rust_postgres_rest::{Config};
74+
/// use postgres_rest::{Config};
7575
/// use tokio_postgres::tls::NoTls;
7676
///
7777
/// let mut config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);
@@ -134,7 +134,7 @@ impl<T: MakeTlsConnect<Socket> + Clone + Send + Sync + 'static> Config<T> {
134134
/// Set the interval timer to automatically reset the table stats cache. If this is not set, the
135135
/// cache is never reset.
136136
/// ```
137-
/// use rust_postgres_rest::Config;
137+
/// use postgres_rest::Config;
138138
/// use tokio_postgres::tls::NoTls;
139139
///
140140
/// let mut config = Config::new("postgresql://[email protected]:5432/postgres", NoTls);

0 commit comments

Comments
 (0)