// lookupProvisioner loads the provisioner associated with the request.
// Responds 404 if the provisioner does not exist.
lookupProvisioner loads the provisioner associated with the request.
Responds 404 if the provisioner does not exist.
// lookupProvisioner loads the provisioner associated with the request . // Responds 404 if the provisioner does not exist .
func (h *Handler) lookupProvisioner(next nextHTTP) nextHTTP {
	return func(w http.ResponseWriter, r *http.Request) {
		name := chi.URLParam(r, "provisionerID")
		provisionerID, err := url.PathUnescape(name)
		if err != nil {
			api.WriteError(w, errors.Errorf("error url unescaping provisioner id '%s'", name))
			return
		}
		p, err := h.Auth.LoadProvisionerByID("scep/" + provisionerID)
		if err != nil {
			api.WriteError(w, err)
			return
		}
		provisioner, ok := p.(*provisioner.SCEP)
		if !ok {
			api.WriteError(w, errors.New("provisioner must be of type SCEP"))
			return
		}
		ctx := r.Context()
		ctx = context.WithValue(ctx, scep.ProvisionerContextKey, scep.Provisioner(provisioner))
		next(w, r.WithContext(ctx))
	}
}
func ( h * Handler ) lookupProvisioner ( next nextHTTP ) nextHTTP { return func ( w http . ResponseWriter , r * http . Request ) { name := chi . URLParam ( r , " " ) provisionerID , err := url . PathUnescape ( name ) if err != nil { api . WriteError ( w , errors . Errorf ( " " , name ) ) return } p , err := h . Auth . LoadProvisionerByID ( " " + provisionerID ) if err != nil { api . WriteError ( w , err ) return } provisioner , ok := p . ( * provisioner . SCEP ) if ! ok { api . WriteError ( w , errors . New ( " " ) ) return } ctx := r . Context ( ) ctx = context . WithValue ( ctx , scep . ProvisionerContextKey , scep . Provisioner ( provisioner ) ) next ( w , r . WithContext ( ctx ) ) } }
lookupProvisioner loads the provisioner associated with the request.
lookupProvisioner loads the provisioner associated with the request .