Https server example

Hello! I'm new to Rust and I'm having a hard time finding the current state of TLS/HTTPS development.

I would like to port this code to Rust, which is a https server using standard Go library. How I would do this in Rust?


// https://github.com/denji/golang-tls

package main

import (
    // "fmt"
    // "io"
    "net/http"
    "log"
)

func HelloServer(w http.ResponseWriter, req *http.Request) {
    w.Header().Set("Content-Type", "text/plain")
    w.Write([]byte("This is an example server.\n"))
    // fmt.Fprintf(w, "This is an example server.\n")
    // io.WriteString(w, "This is an example server.\n")
}

func main() {
    http.HandleFunc("/hello", HelloServer)
    err := http.ListenAndServeTLS(":13001", "server.crt", "server.key", nil)
    if err != nil {
        log.Fatal("ListenAndServe: ", err)
    }
}

There are several ways (crates in particular) to achieve this. You may want to have a look at http://www.arewewebyet.org for an overview.