Table of Contents

Chameleon includes a number of system tables. In This section, these tables, their structure (schema), purpose and how they relate each other or work is explained.

Context Tables

Context tables are tables that relate to a request. They all have a common column named [context_id] of int type that holds the context-id of a request passed to Chameleon. They are divided into three categories:

  • Request tables
  • Response tables
  • Other: routing, request data, errors, etc.

chameleon._request

This table holds basic request specification including its URL, Http method and its body.

Column Type Descrption
context_id int context-id
url nvarchar(2000) URL
method varchar(10) Http method
body nvarchar(max) Request body

chameleon._requestUrl

This table holds details of the URL of a request. When Chameleon receives a request, it inserts details of the received URL into this table. Schema of this table is as follows:

Column Type Descrption Example
context_id int context-id 1
host nvarchar(500) Host www.mysite.com
port int Port 3000
scheme nvarchar(500) Scheme/Protocol http
path nvarchar(2000) Path /product/list
querystring nvarchar(2000) Querystring ?order-by=title&order-dir=desc
hash nvarchar(2000) Hash or fragment #page=1

URL

chameleon._requestHeaders

As the name implies, this table holds request headers. Its schema is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) header name
value nvarchar(max) header value

chameleon._requestCookies

As the name implies, this table holds request cookies. Its schema is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(400) cookie name
value nvarchar(max) cookie value
domain nvarchar(1000) cookie domain
path nvarchar(1000) cookie path
sameSite varchar(30) cookie same-site policy
expires datetime cookie expire date/time
secure bit if cookie is sent only in HTTPS or not
httpOnly bit if cookie is visible in javascript or not

chameleon._requestEnvironment

This table holds host environment variables. Its schema is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) environment item name
value nvarchar(max) environment item value

chameleon._requestForm

This table holds request Form items sent in a POST request. Its schema is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) form item name
value nvarchar(max) form item value

chameleon._requestQuerystring

This table holds querystring parameters in the URL. Its schema is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) querstring parameter name
value nvarchar(max) querstring parameter value

chameleon._requestFiles

This table holds files sent/uploaded together with the request. Its schema is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(1000) form item name
fileName nvarchar(250) filename
content varbinary(max) file content
length bigint file size

chameleon._requestData

This table holds custom key/value items that could be assigned to requests so that the data could be used in the entire pipeline during request processing by application middlewares. One good example of using requestData is setting current user's identity by CookieAuthenticationMiddleware when the request is authenticated, so that later middlewares could use it. Schema of this table is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) item name
value nvarchar(max) item value

chameleon._response

This table holds the final result for received requests. When request is finally processed, Chameleon returns the record provided in this table to the Chameleon Host. Schema of this table is as follows:

Column Type Descrption
context_id int context-id
text nvarchar(max) response body/content for textual contents
body varbinary(max) respone body for binary contents (i.e. files)
fileId int It is possible to specify a fileId (PK of a file record in chameleon.Files table) as the response. In this case, Chameleon automatically returns content of the file as the response body. Chameleon's file-system is explained in File-System section.
status int response status code (200, 404, ...)
bufferSize int This field enables SQL Server streaming. When response content (either textual or binary content) is large, this setting boosts performance as it pipes SQL Server directly to the HTTTP response and bypasses any extra memory allocation.
end bit Determines if the response is finalized and should be ended. When processing a request, Chameleon continues invoking middlewares one by one, checking end field right after invoking a middleware to see if it should end pipeline or not. This is necessary as a middleware may not neccessarily want to end the request. It may just perform an operation related to the request (like logging, setting request data, etc.)

chameleon._responseHeaders

As the name implies, this table holds response headers that should be sent to the client. Its schema is as follows:

Column Type Descrption
context_id int context-id
key nvarchar(400) header name
value nvarchar(max) header value

chameleon._responseCookies

As the name implies, this table holds response cookies that should be sent to the client. Its schema is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(400) cookie name
value nvarchar(max) cookie value
domain nvarchar(1000) cookie domain
path nvarchar(1000) cookie path
sameSite varchar(30) cookie same-site policy
expires datetime cookie expire date/time
secure bit if cookie is sent only in HTTPS or not
httpOnly bit if cookie is visible in javascript or not

chameleon._routeValues

This table is used by RoutingMiddleware and holds routing parameters. Its schema is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(200) route parameter name. e.g. controller, action
value nvarchar(2000) route parameter value. e.g. product
isDefault bit whether the value of this route parameter is set using default value of this parameter specified in the route or not

Framework Tables

chameleon._errors

This table holds any possible errors that may happen during processing a request in the pipeline. Its schema is as follows:

Column Type Descrption
context_id int context-id
errorDate datetime error date/time
key nvarchar(200) error item name, e.g. error_message, error_procedure
value nvarchar(4000) error item value

Chameleon adds the following items to chameleon._errors table when an unhandled error happens in the pipeline.

Item Value
error_line ERROR_LINE()
error_message ERROR_MESSAGE()
error_number ERROR_NUMBER()
error_procedure ERROR_PROCEDURE()
error_severity ERROR_SEVERITY()
error_state ERROR_STATE()

Middleware-Related Tables

RoutingMiddleware

chameleon.Routes

This table holds application routes through which requests are routed to a controller stored-procedure for final processing. The records in this table are used by RoutingMiddleware. In order to learn more about routing, how to define a route, how routes are matched, route parameters, define route constraints and other routing-related topics, please refer to Routing section.

Gila View-Engine

chameleon._viewData

This table is used by Gila view-engine. It holds view data that could be shared by child views so that parent views can consume them. View data in essence is a simple mechanism by which views can interact each other. Schema of chameleon._viewData is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(300) item name
value nvarchar(max) item value

chameleon._sections

Like chameleon._viewData, this table is also used by Gila view-engine. It holds content of sections provided by child views for parent views or templates. Schema of chameleon._viewData is as follows:

Column Type Descrption
context_id int context-id
name nvarchar(300) section name
parent varchar(300) owner of section (parent view who has declared the section)
value nvarchar(max) proided content

In order to learn more about view-engines, click here.

CacheGetMiddleware, CacheSetMiddleware

chameleon.Cache

This table represents a simple cache that is able to store anything in string form that is going to be used later by any consumer. Schema of this table is as follows:

Column Type Descrption
key varchar(200) cached item key
value nvarchar(max) cached item value
duration int Caching duration or how long item can stay in cache (in seconds) to be valid
createdAt datetime date/time when item was added to cache
isValid bit (computed) whether the cached item is still valid or not. It is true (1) if datediff(second, createdAt, getdate()) is less than duration, otherwise it is false (0).
hits int Number of cached item is hitted
lastAccessed datetime last time cached item was accessed

To learn more about Caching in Chameleon click here.