$darkmode
handler.hpp File Reference
#include <functional>
#include <map>
#include <string>
#include <utility>
#include <fable/confable.hpp>
#include <fable/json.hpp>
Include dependency graph for handler.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  cloe::Request
 
class  cloe::Response
 
class  cloe::handler::Redirect
 
class  cloe::handler::StaticJson
 
class  cloe::handler::ToJson< T >
 
class  cloe::handler::FromConf
 

Enumerations

enum class  cloe::RequestMethod { GET = 1 , POST = 2 , PUT = 4 , DELETE = 8 }
 
enum class  cloe::ContentType {
  NOT_APPLICABLE , UNKNOWN , JSON , HTML ,
  CSS , CSV , JAVASCRIPT , TEXT ,
  SVG , PNG
}
 
enum class  cloe::StatusCode {
  OK = 200 , CREATED = 201 , ACCEPTED = 202 , NO_CONTENT = 204 ,
  RESET_CONTENT = 205 , PARTIAL_CONTENT = 206 , MULTIPLE_CHOICES = 300 , MOVED_PERMANENTLY = 301 ,
  FOUND = 302 , SEE_OTHER = 303 , NOT_MODIFIED = 304 , USE_PROXY = 305 ,
  TEMPORARY_REDIRECT = 307 , BAD_REQUEST = 400 , UNAUTHORIZED = 401 , FORBIDDEN = 403 ,
  NOT_FOUND = 404 , NOT_ALLOWED = 405 , NOT_ACCEPTABLE = 406 , REQUEST_TIMEOUT = 408 ,
  CONFLICT = 409 , GONE = 410 , SERVER_ERROR = 500 , NOT_IMPLEMENTED = 501 ,
  SERVICE_UNAVAILABLE = 503
}
 

Functions

const char * cloe::as_cstr (const RequestMethod &m)
 
void cloe::from_string (const std::string &s, RequestMethod &m)
 
const char * cloe::as_cstr (const ContentType &t)
 

Detailed Description

See also
cloe/handler.cpp

This file contains definitions required for defining HTTP handlers for endpoints.

For example, there are simple methods that can be used if all a class wants to do is create an endpoint that returns a JSON object. This file does not specify who acquires handlers from classes, only what those handlers look like.

Dependencies

This file should not have any dependencies to the rest of Cloe apart from what is used as a JSON class. As such, it should be understandable by itself.

Enumeration Type Documentation

◆ ContentType

enum cloe::ContentType
strong

An enumeration of the most common content types.

When returning a response to the web browser, it inspects the content type to determine what to do with the response. It is therefore important that we set the correct content type on responses.

◆ RequestMethod

enum cloe::RequestMethod
strong

An enumeration of the most common request methods.

If a request comes that is unrecognized, UNKNOWN is returned. Currently, the primary methods that we recognize are GET and POST.

◆ StatusCode

enum cloe::StatusCode
strong

An enumeration of the most common status codes.

For more information, see the RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Function Documentation

◆ as_cstr()