Skip to content

TomWright/gracehttpserverrunner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card PkgGoDev GitHub License GitHub tag (latest by date)

Grace HTTP Server Runner

A GRPC Server Runner for use with grace.

Usage

package main

import (
	"context"
	"github.com/tomwright/grace"
	"github.com/tomwright/gracehttpserverrunner"
	"net/http"
	"time"
)

func main() {
	g := grace.Init(context.Background())

	// Create and configure your HTTP server.
	server := &http.Server{
		Addr:    ":8080",
		Handler: http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {}),
	}

	// Create and configure the HTTP server runner.
	runner := &gracehttpserverrunner.HTTPServerRunner{
		Server:  server,
		ShutdownTimeout: time.Second * 5,
	}

	// Run the runner.
	g.Run(runner)

	g.Wait()
}