Skip to content

Playing with Rust, Nickel, Postgres, and more: Example API

Notifications You must be signed in to change notification settings

ptariche/rust_api_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust API Example

Playing with Rust, Nickel, Postgres, Basic API Example

Build Status

About

  • I'm teaching myself rust; this is a very basic example with Nickel and Diesel utilizing Postgres

Pre-requisites

  • Install Rust
  • 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  - ROUTE

GET     - 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

About

Playing with Rust, Nickel, Postgres, and more: Example API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages