https://github.com/ptariche/rust_api_example
Playing with Rust, Nickel, Postgres, and more: Example API
https://github.com/ptariche/rust_api_example
api diesel nickel postgres rust starter
Last synced: 6 months ago
JSON representation
Playing with Rust, Nickel, Postgres, and more: Example API
- Host: GitHub
- URL: https://github.com/ptariche/rust_api_example
- Owner: ptariche
- Created: 2016-05-23T01:47:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-29T23:08:12.000Z (almost 9 years ago)
- Last Synced: 2025-03-28T20:23:32.508Z (7 months ago)
- Topics: api, diesel, nickel, postgres, rust, starter
- Language: Rust
- Homepage:
- Size: 46.9 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Rust API Example
Playing with Rust, Nickel, Postgres, Basic API Example[](https://travis-ci.org/ptariche/rust_api_example)
### About
- I'm teaching myself rust; this is a very basic example with Nickel and Diesel utilizing Postgres### Pre-requisites
- [Install Rust](https://www.rust-lang.org/en-US/install.html)
- Rustup to nightly build required
- curl -s https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly
- rustup update
- rustup install nightly
- rustup run nightly rustc --version
- rustup default nightly
- cargo update
- Postgres
- CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
- cargo install diesel_cli
- diesel setup --database-url='postgres://localhost/postgres'
- DATABASE_URL='postgres://localhost/postgres' diesel migration redo### Routes
```
METHOD - ROUTEGET - http://127.0.0.1:4001/
GET - http://127.0.0.1:4001/person/:uuid/lookup
PUT - http://127.0.0.1:4001/person/:uuid/update
DELETE - http://127.0.0.1:4001/person/:uuid/destroy
POST - http://127.0.0.1:4001/person/create```
### Environment Variables
- PORT
- HOST
- DATABASE_URI## Build
- PORT=4001 HOST=127.0.0.1 DATABASE_URI=postgresql://127.0.0.1:5432/postgres cargo build## Run
- PORT=4001 HOST=127.0.0.1 DATABASE_URI=postgresql://127.0.0.1:5432/postgres cargo run