github.com/blend/go-sdk@v1.20220411.3/web/default_provider_middleware.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package web
     9  
    10  // ViewProviderAsDefault sets the context.DefaultResultProvider() equal to context.View().
    11  func ViewProviderAsDefault(action Action) Action {
    12  	return func(ctx *Ctx) Result {
    13  		ctx.DefaultProvider = ctx.Views
    14  		return action(ctx)
    15  	}
    16  }
    17  
    18  // JSONProviderAsDefault sets the context.DefaultResultProvider() equal to context.JSON().
    19  func JSONProviderAsDefault(action Action) Action {
    20  	return func(ctx *Ctx) Result {
    21  		ctx.DefaultProvider = JSON
    22  		return action(ctx)
    23  	}
    24  }
    25  
    26  // XMLProviderAsDefault sets the context.DefaultResultProvider() equal to context.XML().
    27  func XMLProviderAsDefault(action Action) Action {
    28  	return func(ctx *Ctx) Result {
    29  		ctx.DefaultProvider = XML
    30  		return action(ctx)
    31  	}
    32  }
    33  
    34  // TextProviderAsDefault sets the context.DefaultResultProvider() equal to context.Text().
    35  func TextProviderAsDefault(action Action) Action {
    36  	return func(ctx *Ctx) Result {
    37  		ctx.DefaultProvider = Text
    38  		return action(ctx)
    39  	}
    40  }