Git Product home page Git Product logo

rust-multithreaded-http-server's Introduction

Motivation

This repository was created as a learning tool to comprehend some fundamental Rust methodologies in terms of parallel operations, and creating a HTTP server; which consists of a functioning multithreaded HTTP server, providing a lightweight front end for sending requests to the server.

It was formed by working through project steps of 'The Rust Programming Language' book, with some minor adjustments, added unit tests for the thread pool, and added comments / documentation for public / non-public structs and functions.

Getting Started (steps to run the server)

You must have Rust installed on your system for the server to run:

Once you have Rust installed:

  • Clone this repository.
  • Inside the root of the repository
    • Running cargo check will check that the code is compiling correctly.
    • Inline tests for the ThreadPool can be executed by running cargo test.
    • Start the server by running cargo run.
    • Then in a web browser, navigate to http://217.0.0.1:7878 and you should see the served HTML with the text 'Rust multithreaded HTTP server'.
    • Refreshing this page multiple times will send consecutive requests to the server, which you can view in the terminal.
    • Opening http://217.0.0.1:7878/sleep in another tab, and refresing this page will run a thread on the server which takes 5 seconds to complete, so while this request is waiting to respond to the server, and you refresh the first tab multiple times, in the terminal you will see that the first tab utilises other threads taken from the thread pool, and does not wait for the 'sleeping' thread to finish. A maximum of 4 parallel threads can be utilised at the same time.

Generated documentation can be viewed by running cargo doc --open

The book project details can be viewed here

rust-multithreaded-http-server's People

Contributors

semsion avatar

Stargazers

 avatar

Watchers

 avatar

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.