Giter Club home page Giter Club logo

rust-web-programming's Introduction

Rust Web Programming

Rust Web Programming

This is the code repository for Rust Web Programming, published by Packt.

Setup

In order to run the code in this github, you're going to have to install Rust via the following link:

https://www.rust-lang.org/tools/install

Running Code

The code has to be compiled. In order to do this, we navigate to the file we want to run. For this example, we're using strings.rs in chapter_one. Once we've navigated there, we compile the file using the rustc command:

rustc strings.rs 

On Windows, we then run the exe file:

.\strings.exe

For Linux and Mac, we run using the following:

./strings

JSON Web Token

Please note, Chapter 11, Understanding Rocket Web Framework, and the Appendix A, both utlize a JSON web token. However, the token is not created in the chapter and appendix. Below is a token for a user with the ID of one. This can be copied and pasted for use in the exercises:

eyJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjo2fQ.uVo7u877IT2GEMpB_gxVtxhMAYAJD8W_XiUoNvR7_iM

A hands-on guide to developing fast and secure web apps with the Rust programming language

What is this book about?

This book on web programming with Rust is for web developers who have programmed in traditional languages such as Python, Ruby, JavaScript, and Java and are looking to develop high-performance web applications with Rust. Although no prior experience with Rust is necessary, a solid understanding of web development principles and basic knowledge of HTML, CSS, and JavaScript are required if you want to get the most out of this book.

This book covers the following exciting features: Structure scalable web apps in Rust in Rocket, Actix Web, and Warp Apply data persistence for your web apps using PostgreSQL Build login, JWT, and config modules for your web apps Serve HTML, CSS, and JavaScript from the Actix Web server Build unit tests and functional API tests in Postman and Newman Deploy the Rust app with NGINX and Docker onto an AWS EC2 instance

If you feel this book is for you, get your copy today!

https://www.packtpub.com/

Instructions and Navigations

All of the code is organized into folders. For example, Chapter02.

The code will look like the following:

pretty_env_logger::init();
let log = warp::log("to_do::api");

Following is what you need for this book: This book on web programming with Rust is for web developers who have programmed in traditional languages such as Python, Ruby, JavaScript, and Java and are looking to develop high-performance web applications with Rust. Although no prior experience with Rust is necessary, a solid understanding of web development principles and basic knowledge of HTML, CSS, and JavaScript are required if you want to get the most out of this book.

Code in Action

Please visit the following link to check the CiA videos: http://bit.ly/3jULCrw

With the following software and hardware list you can run all code files present in the book (Chapter 1-11).

Software and Hardware List

No Software required OS required
1 Rust Windows, Mac OS X, and Linux (Any)
2 Docker Windows, Mac OS X, and Linux (Any)
3 Docker-compose Windows, Mac OS X, and Linux (Any)
4 Postman Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Get to Know the Author

Maxwell Flitton is a Software Engineer who works at a financial tech company called Monolith AI. In 2011, Maxwell achieved his Bachelor of Science in Nursing degree from the University of Lincoln, UK. While working 12 hours shifts in the A and E departments of hospitals, Maxwell obtained another degree in Physics from The Open University in the UK and then moved one to another milestone, with a Postgrad Diploma in Physics and Engineering in Medicine from UCL in London. He developed an open source machine learning deployment software called DeployML which can be downloaded via pip and occasionally he teaches computational medicine at Imperial College London every now and then.

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781800560819

rust-web-programming's People

Contributors

gaurav-packt avatar intrepion avatar maxwellflitton avatar packt-itservice avatar packt-pradeeps avatar packtutkarshr avatar rohitpackt avatar rosalc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-web-programming's Issues

Template Strings for CSS, JAVASCRIPT problem

FOR {{BASE_CSS}} in main.html:
I get errors
at-rule or selector expected
{ expected
at-rule or selector expected


{{JAVASCRIPT}}
console
reference error JAVASCRIPT not defined

Ch10_deploy locally

Hey Max,

You did really a great job writing this book. Thank you.

I hope you can give me some advice about an error I am getting here.

On chapter 10 (p.275) after I tried to create an user I got the followed error:
"502 Bad Gateway"

I am still trying to resolve. Could you help me with that?

Thank you

Ch1 struct

Hi,
creating the files along my reading of the book (just begun), for it to compile, I had to do :
`
struct Human {
name: String,
age: i8,
current_thought: String
}

impl Human {-
fn new (name: &str, age: i8) -> Human {
return Human {
name: name.to_string(),
age,
current_thought: String::from("nothing")
}
}

 fn with_thought (mut self, thought: &str ) -> Human {
      self.current_thought  = thought.to_string();
      return self
  }

  fn speak (&self) -> () {
      println! ("Hello my name is {} and I'm {} years old.",
                &self.name,
                &self.age);
  }

}

fn main() {
let developper = Human::new("Grace", 30)
.with_thought("Let's code !");
developper.speak();
println!("Hello, world!");
}
`

I've seen that the code in the repo here is changed from the book's, so I gess this issue is mainly solved with Strings in the repo.

As I've solved it keeping the &str, I just wanted to document another way to fix it.
Best

Sacha

In case anyone runs into a problem getting diesel_cli to install in Chapter 6

I'm working through the excellent tutorials, but I hit a snag when trying to install diesel_cli, in order to connect to PostgreSQL via Docker. The catch is that you need the DB libraries installed locally. I'm on Windows 10 using Ubuntu via WSL, so I kept getting errors, until I ran:

sudo apt install libpq-dev

Everything works after that!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.