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: url_format.go
    path of file: ./repos/corteza/server/vendor/github.com/go-chi/chi/middleware
    
    the code of the file until where you have to start completion: package middleware

import (
	"context"
	"net/http"
	"strings"

	"github.com/go-chi/chi"
)

var (
	// URLFormatCtxKey is the context.Context key to store the URL format data
	// for a request.
	URLFormatCtxKey = &contextKey{"URLFormat"}
)

// URLFormat is a middleware that parses the url extension from a request path and stores it
// on the c
    
func URLFormat(next http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		ctx := r.Context()

		var format string
		path := r.URL.Path

		if strings.Index(path, ".") > 0 {
			base := strings.LastIndex(path, "/")
			idx := strings.Index(path[base:], ".")

			if idx > 0 {
				idx += base
				format = path[idx+1:]

				rctx := chi.RouteContext(r.Context())
				rctx.RoutePath = path[:idx]
			}
		}

		r = r.WithContext(context.WithValue(ctx, URLFormatCtxKey, format))

		next.ServeHTTP(w, r)
	}
	return http.HandlerFunc(fn)
}