Skip to content

🦊 HTTP Server for the MulleFoundation based on civetweb

License

Notifications You must be signed in to change notification settings

MulleWeb/MulleCivetWeb

Repository files navigation

MulleCivetWeb

🦊 HTTP Server for mulle-objc

MulleCivetWeb is a "WebServer as a library". It is based on civetweb.

Release Version Release Notes
Mulle kybernetiK tag Build Status RELEASENOTES

Example

You typically interact with MulleCivetWeb by creating a MulleCivetWebServer object, and by attaching a MulleCivetWebRequestHandler to it:

@interface MyRequestHandler : NSObject < MulleCivetWebRequestHandler>
@end


int   main( int argc, char *argv[])
{
   MulleCivetWebServer  *server;
   MyRequestHandler     *handler;

   server  = [MulleCivetWebServer object];

   // the server is already running now!
   handler = [MyRequestHandler object];
   [server setRequestHandler:handler];

   return( 0);
}

The request handler will receive MulleCivetWebRequests and return MulleCivetWebResponses:

@implementation MyRequestHandler

- (MulleCivetWebResponse *) webResponseForWebRequest:(MulleCivetWebRequest *) request
{
   MulleCivetWebTextResponse   *response; // subclass of MulleCivetWebResponse

   response = [MulleCivetWebTextResponse webResponseForWebRequest:request];
   [response appendFormat:@"Method is %@\n",
                     [request method] == MulleHTTPPost ? @"POST" : @"GET"]
   [response appendFormat:@"Accept-Encoding is %@",
                     [request headerValueForKey:MulleHTTPAcceptEncodingKey]];
   [response appendString:@"Hello World"];
   return( response);
}

@end

That's it.

API

MulleCivetWeb add the following principal classes:

Class Description
MulleCivetWebServer The WebServer class. Add your request handler to it.
MulleCivetWebRequest Requests as received by the MulleCivetWebServer
MulleCivetWebResponse Responses returned by a request handler. They contain header
MulleCivetWebTextResponse Subclass of MulleCivetWebResponse to produce plain text, JSON,

You are here

Overview

Add

Use mulle-sde to add MulleCivetWeb to your project:

mulle-sde add github:MulleWeb/MulleCivetWeb

Install

Install with mulle-sde

Use mulle-sde to build and install MulleCivetWeb and all dependencies:

mulle-sde install --prefix /usr/local \
   https://github.com//MulleCivetWeb/archive/latest.tar.gz

Manual Installation

Install the requirements:

Requirements Description
MulleObjCHTTPFoundation 🎫 HTTP and HTML utility methods and classes for mulle-objc
MulleFoundation 💍 Umbrella library for the MulleFoundation
mulle-objc-list 📒 Lists mulle-objc runtime information contained in executables.

Download the latest tar or zip archive and unpack it.

Install MulleCivetWeb into /usr/local with cmake:

cmake -B build \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DCMAKE_PREFIX_PATH=/usr/local \
      -DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release

Platforms and Compilers

All platforms and compilers supported by mulle-c11.

Author

Nat! for Mulle kybernetiK