GithubHelp home page GithubHelp logo

go-nghttp2's Introduction

go-nghttp2

The experimental project to use nghttp2 C library from Go using cgo. Currently, server implementation is available.

How to run demo server

First, build and install nghttp2. Do git clone https://github.com/tatsuhiro-t/go-nghttp2.git and enter demo directory. Then run go run demo.go. It fires up HTTP/2 capable https server listening at port 3000. It also supports HTTP/1 connection.

nghttp2.Server only supports https HTTP/2 connection right now.

Example

package main

import (
        "github.com/tatsuhiro-t/go-nghttp2"
        "io"
        "log"
        "net/http"
)

func main() {
        var srv http.Server
        srv.Addr = "localhost:3000"

        http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
                io.WriteString(w, "hello world")
        })
        // Set up srv so that if HTTP/2 is negotiated in TLS NPN,
        // connection is intercepted by nghttp2.Server.
        nghttp2.ConfigureServer(&srv, &nghttp2.Server{})

        log.Printf("Listening on " + srv.Addr)
        log.Fatal(srv.ListenAndServeTLS("server.crt", "server.key"))
}

go-nghttp2's People

Contributors

tatsuhiro-t avatar

Watchers

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