func NewServer(cfg *Config, index dim.RegistryIndex, ctx context.Context, proxy dim.RegistryProxy) *Server {
	c := environment.Set(ctx, environment.StartTimeKey, time.Now())
	http.HandleFunc("/v1/search", securityFilter(cfg, handler(index, Search)))
	http.HandleFunc("/dim/notify", securityFilter(cfg, handler(index, NotifyImageChange)))
	http.HandleFunc("/dim/version", securityFilter(cfg, buildVersionHandler(c)))
	http.HandleFunc("/", securityFilter(cfg, proxy.Forwards))
	return &Server{manners.NewWithServer(&http.Server{Addr: cfg.Port, Handler: http.DefaultServeMux}), index}
}
NewServer creates a new Server instance to listen on given port and use given index
package server
import (
	"encoding/json"
	"fmt"
	"net/http"
	"strconv"
	"time"
	"context"
	"github.com/Sirupsen/logrus"
	"github.com/docker/distribution/manifest/schema2"
	"github.com/docker/distribution/notifications"
	"github.com/mailgun/manners"
	"github.com/nhurel/dim/lib"
	"github.com/nhurel/dim/lib/environment"
)
type Server struct {
	*manners.GracefulServer
	index dim.RegistryIndex
}