Popularity
0.6
Stable
Activity
0.0
Stable
8
1
1

Description

FastCGI it's great solutions to handling HTTP-requests without overhead. Completely supporting HTTP or HTTPS by any popular web-servers.

Programming language: Rust
License: MIT License
Tags: Web     Web Programming     HTTP     HTTP Server     https     Fastcgi     Fcgi    

The FastCGI Rust implementation. alternatives and similar packages

Based on the "HTTP Server" category.
Alternatively, view The FastCGI Rust implementation. alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of The FastCGI Rust implementation. or a related project?

Add another 'HTTP Server' Package

README

The FastCGI Rust implementation.

Build Status docs.rs Cargo [MIT licensed](LICENSE)

Description

gfcgi is a native Rust library for FastCGI.
This library supports multithreaded socket listeners and HTTP-instances multiplexed onto a single connection.

About FastCGI

FastCGI is a great solution to handling HTTP-requests without overhead. Completely supporting HTTP or HTTPS by any of the leading popular web-servers (Apache HTTPd, nginx, etc).

[Specification](doc/fcgi-spec.md)

Example

Import the library within your code.

    extern crate gfcgi;

    use std::io::{Read, Write}; 
    use std::thread;

An example of a router struct

    #[derive(Clone)]
    struct Router;

    impl Router
    {
        fn new() -> Self
        { 
            Router{}
        }
    }

Implement gfcgi::Handler trait for your router, all code in process method is optional

    impl gfcgi::Handler for Router
    {
        fn process(&self, request: &mut gfcgi::Request, response: &mut gfcgi::Response)
        {
            // get a header
            println!("{:?}", request.header_utf8(b"HTTP_HOST"));

            // read content
            let mut buf = Vec::new();
            request.read_to_end(&mut buf).unwrap();
            println!("{:?}", String::from_utf8(buf));

            // set header
            response.status(200);
            response.header_utf8("Content-type", "text/plain");

            // send content
            response.write(b"hello world!").expect("send body");

        }
    }

Now run listener, you can spawn threads if the spawn feature is set in Cargo.toml

    fn main()
    {
        let client = gfcgi::Client::new("127.0.0.1:4128");

        // run listener
        client.run(Router::new());

        if cfg!(feature = "spawn") {
            client.run(Router::new()); // spawn worker
        }

        thread::park(); // keep main process
    }

Planned

  • [x] Role
    • [x] responder
    • [ ] filter
    • [ ] authorizer
  • [x] Header
    • [ ] get_values
    • [ ] get_values_result
    • [x] unknown_type
    • [x] begin_request
    • [x] abort_request
    • [x] end_request
    • [x] params
    • [x] stdin
    • [ ] data
    • [x] stdout
    • [ ] stderr

Trace

socket
    stream
        connection
        handler
            request
            | โ†’ read headers
            | โ†’ [read body]
            response
            | โ† write headers
            | โ† [write body]


*Note that all licence references and agreements mentioned in the The FastCGI Rust implementation. README section above are relevant to that project's source code only.