IWebApi Interface

Provide methods to interact with current http request.

Definition

Namespace: Casewhere.WebTrigger.DSL
Assembly: Casewhere.WebTrigger (in Casewhere.WebTrigger.dll) Version: 1.0.0.0 (1.0.0.0)
C#
public interface IWebApi

Methods

AbandonAuthorization Stop the flow of initial authorization
CreateErrorResponse Create http error response with status code and message

Example

C#
var webApi = ctx.Use<IWebApi>();
webApi.CreateErrorResponse(401, "You are not authorized");
CreateFileResponse(DocumentInfo, String, String) Create http file response with a given document info, media type and disposition header. The file can be downloaded or will be viewed in the browser client.
CreateFileResponse(String, ActionStream, String, String) Create http file response with a given file name with an action named as beginWritingStream. That action is called when an output stream is available, allowing the action to write to it directly. Thus, allow we can write a largest file (more than 1GB with controlling memory usage).
CreateFileResponse(String, Byte, String, String) Create http file response with a given file name, file content, media type and disposition header. The file can be downloaded or will be viewed in the browser client.
CreateFileResponse(String, Stream, String, String) Create http file response with a given file name, file stream, media type and disposition header. The file can be downloaded or will be viewed in the browser client.
CreateFileResponse(String, String, String, String) Create http file response with a given file name, file path, media type and disposition header. The file can be downloaded or will be viewed in the browser client.
CreateResponseT Create http response with data

Example

C#
var webApi = ctx.Use<IWebApi>();
var data = new { FirstName = "Thao", LastName = "Dinh" };        
webApi.CreateResponse(data);
CreateTextResponse Create http response with text data
GetBrowserAgent Get the complete user-agent string of the client
GetHeaders Get headers from the current request

Example

C#
var webApi = ctx.Use<IWebApi>();        
var headers = webApi.GetHeaders();
GetQueryString Get query string from the current request

Example

C#
var webApi = ctx.Use<IWebApi>();        
var queryString = webApi.GetQueryString();
GetUri Get URI from the current request

Example

C#
var webApi = ctx.Use<IWebApi>();        
var uri = webApi.GetUri();
GetUserIp Get current user ip
Redirect Redirect the specific url

Example

C#
var webApi = ctx.Use<IWebApi>();        
webApi.Redirect("https://api-local.casewhere.com/external/v0.1/trigger/kk-nemlogin-logout-callback?nonce=b3c7c6ea-f38a-4b2a-aa6e-9c69fce65ec1");

See Also