You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: hooks_router.go
    path of file: ./repos/cds/engine/hooks
    
    the code of the file until where you have to start completion: package hooks

import (
	"bytes"
	"context"
	"crypto/hmac"
	"crypto/rsa"
	"crypto/sha256"
	"encoding/hex"
	"io"
	"net/http"
	"strings"
	"sync"

	"github.com/gorilla/mux"
	"github.com/rockbears/log"
	"gopkg.in/spacemonkeygo/httpsig.v0"

	"github.com/ovh/cds/engine/service"
	"github.com/ovh/cds/sdk"
)

func (s *Service) initRouter(ctx context.Context) {
	r := s.Router
	r.Mux.UseEncodedPath()
	r.Background = ctx
	r.URL = s.Cfg.URL
	r.SetHeaderFunc = service.DefaultHeaders
	r.Middlewares = append(r.Middlewares, service.TracingMiddlewareFunc(s))
	r.DefaultAuthMiddleware = service.CheckRequestSignatureMiddleware(s.ParsedAPIPublicKey)
	//r.PostAuthMiddlewares nothing here
	r.PostMiddlewares = append(r.PostMiddlewares, service.TracingPostMiddleware)

	r.Handle("/admin/maintenance", nil, r.POST(s.postMaintenanceHandler))
	r.Handle("/admin/repository/event/{vcsServer}/{repoName}/{uuid}/restar
    
func (s *Service) CheckHmac256Signature(headerName string) service.Middleware {
	return func(ctx context.Context, w http.ResponseWriter, req *http.Request, rc *service.HandlerConfig) (context.Context, error) {
		signHeaderValue := req.Header.Get(headerName)
		if signHeaderValue == "" {
			return ctx, sdk.NewErrorFrom(sdk.ErrUnauthorized, "unable to check signature")
		}
		vars := mux.Vars(req)
		vcsType := vars["vcsServerType"]
		vcsName := vars["vcsServer"]

		defer req.Body.Close() // nolint
		body, err := io.ReadAll(req.Body)
		if err != nil {
			log.ErrorWithStackTrace(ctx, err)
			return ctx, sdk.NewErrorFrom(sdk.ErrUnauthorized, "unable to check signature")
		}

		eventName, err := s.extractEventFromHeader(ctx, vcsType, req.Header)
		if err != nil {
			log.ErrorWithStackTrace(ctx, err)
			return ctx, sdk.NewErrorFrom(sdk.ErrUnauthorized, "unable to extract event from header")
		}

		repoName, _, err := s.extractDataFromPayload(req.Header, vcsType, body, eventName)
		if err != nil {
			log.ErrorWithStackTrace(ctx, err)
			return ctx, sdk.NewErrorFrom(sdk.ErrNotFound, "unable to find repository")
		}

		newRequestBody := io.NopCloser(bytes.NewBuffer(body))
		req.Body = newRequestBody

		// Create a new HMAC by defining the hash type and the key (as byte array)
		hookKey := sdk.GenerateRepositoryWebHookSecret(s.Cfg.RepositoryWebHookKey, vcsName, repoName)
		h := hmac.New(sha256.New, []byte(hookKey))
		h.Write(body)
		sha := hex.EncodeToString(h.Sum(nil))

		if strings.TrimPrefix(signHeaderValue, "sha256=") != sha {
			log.Error(ctx, "signature mismatch: got %s, compute %s", signHeaderValue, sha)
			return ctx, sdk.NewErrorFrom(sdk.ErrUnauthorized, "wrong signature")
		}
		return ctx, nil
	}
}