Crow  1.1
A C++ microframework for the web
crow Namespace Reference

The main namespace of the library. In this namespace is defined the most important classes and functions of the library. More...

Namespaces

 multipart
 Encapsulates anything related to processing and organizing multipart/xyz messages.
 
 mustache
 In this namespace is defined most of the functions and classes related to template rendering.
 
 websocket
 Namespace that includes the Connection class and connection struct. Useful for WebSockets connection.
 

Classes

class  Crow
 The main server application class. More...
 
struct  ci_hash
 Hashing function for ci_map (unordered_multimap). More...
 
struct  ci_key_eq
 Equals function for ci_map (unordered_multimap). More...
 
struct  routing_handle_result
 
struct  bad_request
 
class  Connection
 An HTTP connection. More...
 
struct  http_parser
 
struct  http_parser_settings
 
struct  request
 An HTTP request. More...
 
struct  response
 HTTP response. More...
 
class  Server
 
class  ILogHandler
 
class  CerrLogHandler
 
class  logger
 
struct  ILocalMiddleware
 Local middleware should extend ILocalMiddleware. More...
 
struct  CookieParser
 
struct  CORSRules
 Used for tuning CORS policies. More...
 
struct  CORSHandler
 CORSHandler is a global middleware for setting CORS headers. More...
 
struct  SessionMiddleware
 
struct  InMemoryStore
 InMemoryStore stores all entries in memory. More...
 
struct  FileStore
 
struct  UTF8
 
struct  HTTPParser
 A wrapper for nodejs/http-parser. More...
 
class  query_string
 A class to represent any data coming after the ? in the request URL into key-value pairs. More...
 
struct  returnable
 An abstract class that allows any other class to be returned by a handler. More...
 
class  BaseRule
 A base class for all rules. More...
 
class  CatchallRule
 
class  WebSocketRule
 A rule dealing with websockets. More...
 
struct  RuleParameterTraits
 Allows the user to assign parameters using functions. More...
 
class  DynamicRule
 A rule that can change its parameters during runtime. More...
 
class  TaggedRule
 Default rule created when CROW_ROUTE is called. More...
 
class  Trie
 A search tree. More...
 
class  Blueprint
 A blueprint can be considered a smaller section of a Crow app, specifically where the router is concerned. More...
 
class  Router
 Handles matching requests to existing rules and upgrade requests. More...
 
struct  SocketAdaptor
 A wrapper for the asio::ip::tcp::socket and asio::ssl::stream. More...
 
struct  SSLAdaptor
 

Typedefs

using ssl_context_t = asio::ssl::context
 
template<typename... Middlewares>
using App = Crow< Middlewares... >
 Alias of Crow<Middlewares...>. Useful if you want a instance of an Crow application that require Middlewares.
 
using SimpleApp = Crow<>
 Alias of Crow<>. Useful if you want a instance of an Crow application that doesn't require of Middlewares.
 
using ci_map = std::unordered_multimap< std::string, std::string, ci_hash, ci_key_eq >
 
using error_code = asio::error_code
 
using tcp = asio::ip::tcp
 
typedef struct http_parser http_parser
 
typedef struct http_parser_settings http_parser_settings
 
typedef int(* http_data_cb) (http_parser *, const char *at, size_t length)
 
typedef int(* http_cb) (http_parser *)
 

Enumerations

enum class  HTTPMethod : char {
  DELETE = 0 , GET , HEAD , POST ,
  PUT , CONNECT , OPTIONS , TRACE ,
  PATCH , PURGE , COPY , LOCK ,
  MKCOL , MOVE , PROPFIND , PROPPATCH ,
  SEARCH , UNLOCK , BIND , REBIND ,
  UNBIND , ACL , REPORT , MKACTIVITY ,
  CHECKOUT , MERGE , MSEARCH , NOTIFY ,
  SUBSCRIBE , UNSUBSCRIBE , MKCALENDAR , LINK ,
  UNLINK , SOURCE , Delete = 0 , Get ,
  Head , Post , Put , Connect ,
  Options , Trace , Patch , Purge ,
  Copy , Lock , MkCol , Move ,
  Propfind , Proppatch , Search , Unlock ,
  Bind , Rebind , Unbind , Acl ,
  Report , MkActivity , Checkout , Merge ,
  MSearch , Notify , Subscribe , Unsubscribe ,
  MkCalendar , Link , Unlink , Source ,
  InternalMethodCount
}
 
enum  status {
  CONTINUE = 100 , SWITCHING_PROTOCOLS = 101 , OK = 200 , CREATED = 201 ,
  ACCEPTED = 202 , NON_AUTHORITATIVE_INFORMATION = 203 , NO_CONTENT = 204 , RESET_CONTENT = 205 ,
  PARTIAL_CONTENT = 206 , MULTIPLE_CHOICES = 300 , MOVED_PERMANENTLY = 301 , FOUND = 302 ,
  SEE_OTHER = 303 , NOT_MODIFIED = 304 , TEMPORARY_REDIRECT = 307 , PERMANENT_REDIRECT = 308 ,
  BAD_REQUEST = 400 , UNAUTHORIZED = 401 , FORBIDDEN = 403 , NOT_FOUND = 404 ,
  METHOD_NOT_ALLOWED = 405 , NOT_ACCEPTABLE = 406 , PROXY_AUTHENTICATION_REQUIRED = 407 , CONFLICT = 409 ,
  GONE = 410 , PAYLOAD_TOO_LARGE = 413 , UNSUPPORTED_MEDIA_TYPE = 415 , RANGE_NOT_SATISFIABLE = 416 ,
  EXPECTATION_FAILED = 417 , PRECONDITION_REQUIRED = 428 , TOO_MANY_REQUESTS = 429 , UNAVAILABLE_FOR_LEGAL_REASONS = 451 ,
  INTERNAL_SERVER_ERROR = 500 , NOT_IMPLEMENTED = 501 , BAD_GATEWAY = 502 , SERVICE_UNAVAILABLE = 503 ,
  GATEWAY_TIMEOUT = 504 , VARIANT_ALSO_NEGOTIATES = 506
}
 
enum class  ParamType : char {
  INT , UINT , DOUBLE , STRING ,
  PATH , MAX
}
 
enum  http_connection_flags {
  F_CHUNKED = 1 << 0 , F_CONNECTION_KEEP_ALIVE = 1 << 1 , F_CONNECTION_CLOSE = 1 << 2 , F_TRAILING = 1 << 3 ,
  F_UPGRADE = 1 << 4 , F_SKIPBODY = 1 << 5 , F_CONTENTLENGTH = 1 << 6
}
 
enum  http_errno
 
enum  state {
  s_dead = 1 , s_start_req , s_req_method , s_req_spaces_before_url ,
  s_req_schema , s_req_schema_slash , s_req_schema_slash_slash , s_req_server_start ,
  s_req_server , s_req_server_with_at , s_req_path , s_req_query_string_start ,
  s_req_query_string , s_req_http_start , s_req_http_H , s_req_http_HT ,
  s_req_http_HTT , s_req_http_HTTP , s_req_http_I , s_req_http_IC ,
  s_req_http_major , s_req_http_dot , s_req_http_minor , s_req_http_end ,
  s_req_line_almost_done , s_header_field_start , s_header_field , s_header_value_discard_ws ,
  s_header_value_discard_ws_almost_done , s_header_value_discard_lws , s_header_value_start , s_header_value ,
  s_header_value_lws , s_header_almost_done , s_chunk_size_start , s_chunk_size ,
  s_chunk_parameters , s_chunk_size_almost_done , s_headers_almost_done , s_headers_done ,
  s_chunk_data , s_chunk_data_almost_done , s_chunk_data_done , s_body_identity ,
  s_body_identity_eof , s_message_done
}
 
enum  header_states {
  h_general = 0 , h_C , h_CO , h_CON ,
  h_matching_connection , h_matching_proxy_connection , h_matching_content_length , h_matching_transfer_encoding ,
  h_matching_upgrade , h_connection , h_content_length , h_content_length_num ,
  h_content_length_ws , h_transfer_encoding , h_upgrade , h_matching_transfer_encoding_token_start ,
  h_matching_transfer_encoding_chunked , h_matching_transfer_encoding_token , h_matching_connection_keep_alive , h_matching_connection_close ,
  h_transfer_encoding_chunked , h_connection_keep_alive , h_connection_close
}
 
enum  http_host_state {
  s_http_host_dead = 1 , s_http_userinfo_start , s_http_userinfo , s_http_host_start ,
  s_http_host_v6_start , s_http_host , s_http_host_v6 , s_http_host_v6_end ,
  s_http_host_v6_zone_start , s_http_host_v6_zone , s_http_host_port_start , s_http_host_port
}
 
enum class  LogLevel {
  DEBUG = 0 , INFO , WARNING , ERROR ,
  CRITICAL , Debug = 0 , Info , Warning ,
  Error , Critical
}
 

Functions

const std::string crlf ("\r\n")
 
std::string method_name (HTTPMethod method)
 
enum state parse_url_char (enum state s, const char ch, http_parser *parser, const char *url_mark, const char *p)
 
size_t http_parser_execute (http_parser *parser, const http_parser_settings *settings, const char *data, size_t len)
 
void http_parser_init (http_parser *parser)
 
const char * http_errno_name (enum http_errno err)
 
const char * http_errno_description (enum http_errno err)
 
int http_body_is_final (const struct http_parser *parser)
 
void http_parser_set_max_header_size (uint32_t size)
 
template<typename T >
const std::string & get_header_value (const T &headers, const std::string &key)
 Find and return the value associated with the key. (returns an empty string if nothing is found)
 
int qs_strncmp (const char *s, const char *qs, size_t n)
 
size_t qs_parse (char *qs, char *qs_kv[], size_t qs_kv_size, bool parse_url)
 
int qs_decode (char *qs)
 
char * qs_k2v (const char *key, char *const *qs_kv, size_t qs_kv_size, int nth)
 
char * qs_scanvalue (const char *key, const char *qs, char *val, size_t val_len)
 
std::unique_ptr< std::pair< std::string, std::string > > qs_dict_name2kv (const char *dict_name, char *const *qs_kv, size_t qs_kv_size, int nth=0)
 

Variables

const char cr = '\r'
 
const char lf = '\n'
 
constexpr const char * method_strings []
 
const std::unordered_map< std::string, std::string > mime_types
 
constexpr const uint16_t INVALID_BP_ID {((uint16_t)-1)}
 
const int RULE_SPECIAL_REDIRECT_SLASH = 1
 
constexpr const char VERSION [] = "master"
 

Detailed Description

The main namespace of the library. In this namespace is defined the most important classes and functions of the library.

Within this namespace, the Crow class, Router class, Connection class, and other are defined.