Hyelicht 2.0
Controller application for the Hyelicht shelf. Paint on the shelf with colors, turn on the fireplace mode, and more.
Loading...
Searching...
No Matches
Signals | Public Member Functions | Properties | List of all members
HttpServer Class Reference

HTTP REST API binding and server for ShelfModel. More...

#include <httpserver.h>

Inheritance diagram for HttpServer:
Inheritance graph
[legend]
Collaboration diagram for HttpServer:
Collaboration graph
[legend]

Signals

void enabledChanged () const
 The server has turned on or off.
 
void listenAddressChanged () const
 The listen address for the server has changed.
 
void portChanged () const
 The port the server listens on has changed.
 
void modelChanged ()
 The ShelfModel instance this server provides a HTTP REST API binding for has changed.
 

Public Member Functions

 HttpServer (QObject *parent=nullptr)
 Create a HTTP REST API server.
 
bool enabled () const
 Whether the server is on or off.
 
void setEnabled (bool enabled)
 Turn the server on or off.
 
QString listenAddress () const
 The listen address for the server.
 
void setListenAddress (const QString &listenAddress)
 Set the listen address for the server.
 
int port () const
 The port the server listens on.
 
void setPort (int port)
 Set the port the server listens on.
 
ShelfModelmodel () const
 The ShelfModel instance this server provides a HTTP REST API binding for.
 
void setModel (ShelfModel *model)
 Set the ShelfModel instance this server provides a HTTP REST API binding for.
 
void classBegin () override
 Implements the QQmlParserStatus interface.
 
void componentComplete () override
 Implements the QQmlParserStatus interface.
 

Properties

bool enabled
 Toggle the server on or off.
 
QString listenAddress
 Listen address for the server.
 
int port
 Port the server listens on.
 
ShelfModelmodel
 ShelfModel instance this server provides a HTTP REST API binding for.
 

Detailed Description

HTTP REST API binding and server for ShelfModel.

Implements a read-write HTTP REST API binding and server around the data model and business logic of a ShelfModel instance.

The implementation makes use of the QHttpEngine library.

In the Hyelicht project, the HTTP REST API is used by the included hyelichtctl CLI frontend utility and the diyHue integration plugin.

See also
ShelfModel
QHttpEngine::Server
QHttpEngine::QObjectHandler
QQmlParserStatus

Constructor & Destructor Documentation

◆ HttpServer()

HttpServer::HttpServer ( QObject *  parent = nullptr)
explicit

Create a HTTP REST API server.

Parameters
parentParent object

Member Function Documentation

◆ enabled()

bool HttpServer::enabled ( ) const

Whether the server is on or off.

Returns
Server on or off.
See also
enabled (property)
setEnabled
enabledChanged

◆ enabledChanged

void HttpServer::enabledChanged ( ) const
signal

The server has turned on or off.

See also
enabled
setEnabled

◆ listenAddress()

QString HttpServer::listenAddress ( ) const

The listen address for the server.

Returns
Listen address.
See also
listenAddress (property)
setListenAddress
listenAddressChanged
port

◆ listenAddressChanged

void HttpServer::listenAddressChanged ( ) const
signal

The listen address for the server has changed.

See also
listenAddress
setListenAddress

◆ model()

ShelfModel * HttpServer::model ( ) const

The ShelfModel instance this server provides a HTTP REST API binding for.

Returns
ShelfModel instance.
See also
model (property)
setModel
modelChanged

◆ modelChanged

void HttpServer::modelChanged ( )
signal

The ShelfModel instance this server provides a HTTP REST API binding for has changed.

See also
model
setModel

◆ port()

int HttpServer::port ( ) const

The port the server listens on.

Returns
Port number.
See also
port (property)
setPort
portChanged
listenAddress

◆ portChanged

void HttpServer::portChanged ( ) const
signal

The port the server listens on has changed.

See also
port
setPort

◆ setEnabled()

void HttpServer::setEnabled ( bool  enabled)

Turn the server on or off.

Parameters
enabledServer on or off.
See also
enabled
enabledChanged

◆ setListenAddress()

void HttpServer::setListenAddress ( const QString &  listenAddress)

Set the listen address for the server.

Parameters
listenAddressListen address.
See also
listenAddress
listenAddressChanged
port

◆ setModel()

void HttpServer::setModel ( ShelfModel model)

Set the ShelfModel instance this server provides a HTTP REST API binding for.

Needs to be set to a valid instance for the REST API to be available on the server.

Parameters
modelShelfModel instance.
See also
model
modelChanged

◆ setPort()

void HttpServer::setPort ( int  port)

Set the port the server listens on.

Parameters
portPort number.
See also
port
portChanged
listenAddress

Property Documentation

◆ enabled

bool HttpServer::enabled
readwrite

Toggle the server on or off.

Defaults to false.

See also
setEnabled
enabledChanged
listenAddress
port

◆ listenAddress

QString HttpServer::listenAddress
readwrite

Listen address for the server.

Defaults to 127.0.0.1.

See also
setListenAddress
listenAddressChanged
port

◆ model

ShelfModel* HttpServer::model
readwrite

ShelfModel instance this server provides a HTTP REST API binding for.

Needs to be set to a valid instance for the REST API to be available on the server.

Defaults to nullptr.

See also
setModel
modelChanged

◆ port

int HttpServer::port
readwrite

Port the server listens on.

Defaults to 8082.

See also
setPort
portChanged
listenAddress

The documentation for this class was generated from the following files: