Giter VIP home page Giter VIP logo

rust-web's Introduction

Working with the web in Rust

The main thrust of this is to show the basics of working with Iron. Iron uses Hyper as it's http library, so it's good to know a bit about how that works as well. The hyper and hyper-client projects show what that's all about.

Building

Recently, OSX has deprecated openssl in favor of apple's own TLS library. This means that openssl libs and headers may not be discovered automatically. If you get any errors compiling on OSX, try setting the environment variables: OPENSSL_INCLUDE_DIR, and OPENSSL_LIB_DIR. If you've installed openssl using homebrew (brew install openssl), then these should be:

export OPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include
export OPENSSL_LIB_DIR=/usr/local/opt/openssl/lib

Strengths of Iron

  • Modular and extensible - It's got a lot of exposed wiring, so it's pretty easy to modify or extend it in whatever way you please.
  • Light weight - Features are all opt-in by adding the dependency, so Iron itself if really pretty tiny.
  • Fast - The examples here all run in a matter of microseconds on my macbook.
  • Simple - There's no automagical features here. Unlike some of the big full-stack frameworks, its pretty easy to locate problems in your code.

This is still very new

There are many things that you'd expect a framework to provide. Iron currently provides very few of them. Many of the features that we've come to expect out of web 'frameworks' either don't exist or are in very early stages of development. Additionally, many of the things that we expect to work out of the box with other frameworks must be configured manually with Iron. Don't let the word 'framework' fool you. To compare it to the Java world, Iron is much closer to a pure Servlet than it is to something like SpringMVC.

Things that you have to configure manually

  • Sessions - Actually managing the sessions is still pretty much up to you, even once sessions have been configured.
  • Authentication - The crypto crate has rust implementations of most of the hashing algorithms you might need, but actually using them to authenticate a user is up to you.
  • Body/Parameter parsing - The bodyparser crate will even convert a JSON body to an instance of your struct! There's also a crate for making arbitrary parameters available in a map.
  • Serialization/Deserialization - Going between JSON and structs is pretty easy and well supported.
  • Compression - Pretty simple to setup a gzip on all outgoing pages.
  • Serving static files - This crate can also handle some basic caching using Cache-Control and If-Modified-Since headers.
  • Logging - It's there, but it's definitely not as fancy as what you've probably come to expect from a web framework
  • Content negotiation - Limited support, but the crate appears to be in active development.

Things that are still missing or incomplete

  • Database access - There's more options here than there used to be. Postgres and Redis both have good drivers in rust, and MongoDB isn't far off. There's even an ORM, Diesel. Compared to other languages, options are still rather limited.
  • Authorization - You'll have to roll your own. The crypto crate has most of the main hashing algorithms, but actually calling them is up to you.
  • Helpers for common configurations don't really exist. The Rustless project is taking a stab at it for REST APIs, but that's about it.

rust-web's People

Contributors

psfried avatar

Stargazers

 avatar

Watchers

 avatar  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.