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: listFrontends.go
    path of file: ./repos/zrok/controller
    
    the code of the file until where you have to start completion: package controller

import (
	"github.com/go-openapi/runtime/middleware"
	"github.com/openziti/zrok/rest_model_zrok"
	"github.com/openziti/zrok/rest_server_zrok/operations/admin"
	"github.com/sirupsen/logrus"
)

type listFrontendsHandler struct{}

func newListFrontendsHandler() *listFrontendsHandler {
	return &listFrontendsHandler{}
}

func (h *listFrontendsHandler) Handle(params admin.ListFrontendsParams, principal *rest_model_zrok.Principal) middleware.Responder {
	if !principal.Admin {
		logrus.Errorf("invalid admin principal")
		return admin.NewListFrontendsUnauthorized()
	}

	tx, err := str.Begin()
	if err != nil {
		logrus.Errorf("error starting transaction: %v", err)
		return admin.NewListFrontendsInternalServerError()
	}
	
    
func (h *listFrontendsHandler) Handle(params admin.ListFrontendsParams, principal *rest_model_zrok.Principal) middleware.Responder {
	if !principal.Admin {
		logrus.Errorf("invalid admin principal")
		return admin.NewListFrontendsUnauthorized()
	}

	tx, err := str.Begin()
	if err != nil {
		logrus.Errorf("error starting transaction: %v", err)
		return admin.NewListFrontendsInternalServerError()
	}
	defer func() { _ = tx.Rollback() }()

	sfes, err := str.FindPublicFrontends(tx)
	if err != nil {
		logrus.Errorf("error finding public frontends: %v", err)
		return admin.NewListFrontendsInternalServerError()
	}

	var frontends rest_model_zrok.PublicFrontendList
	for _, sfe := range sfes {
		frontend := &rest_model_zrok.PublicFrontend{
			Token:     sfe.Token,
			ZID:       sfe.ZId,
			CreatedAt: sfe.CreatedAt.UnixMilli(),
			UpdatedAt: sfe.UpdatedAt.UnixMilli(),
		}
		if sfe.UrlTemplate != nil {
			frontend.URLTemplate = *sfe.UrlTemplate
		}
		if sfe.PublicName != nil {
			frontend.PublicName = *sfe.PublicName
		}
		frontends = append(frontends, frontend)
	}
	return admin.NewListFrontendsOK().WithPayload(frontends)
}