Skip to content

πŸ€½πŸ»β€β™‚οΈ Web Server library for mulle-objc

License

Notifications You must be signed in to change notification settings

MulleWeb/MulleWebServer

Repository files navigation

MulleWebServer

πŸ€½πŸ»β€β™‚οΈ Web Server based on civetweb for mulle-objc

This is a small WebServer library written on top of the MulleFoundation.

It contains an HTTP server and support for JSON. It is experimental at this stage.

Release Version Release Notes
Mulle kybernetiK tag Build Status RELEASENOTES

Example

Serving a NSDictionary to the net can be done like this:

//
// define a handler to service web requests, that answers
// http://<host>:8080/foo requests
//
@interface MyWebRequestHandler : MulleObject <MulleCivetWebRequestHandler,
                                              MulleAutolockingObjectProtocols>
@end


@implementation MyWebRequestHandler

- (MulleCivetWebResponse *) webServer:(MulleCivetWebServer *) server
             webResponseForWebRequest:(MulleCivetWebRequest *) request
{
   MulleCivetWebTextResponse   *response;
   NSDictionary                *dictionary;

   if( [[[request URL] path] isEqualToString:@"foo"])
   {
      response   = [MulleCivetWebTextResponse webResponseForWebRequest:request];
      dictionary = @{ @"foo": @"VfL Bochum 1848" };
      [response appendLine:[dictionary mulleJSONDescription]];

      return( response);
   }
   return( nil);
}

@end


int  main( void)
{
   MyWebRequestHandler   *handler;
   MulleCivetWebServer   *server;

   // install request handler in server
   handler = [MyWebRequestHandler object];
   server  = [MulleCivetWebServer object];
   [server setRequestHandler:handler];

   // let server run until CTRL-C or signal
   for(;getchar() != 'q';);

   return( 0);
}

This library ties MulleCivetWebServer to MulleObjCOSFoundation to gain logging functionality.

You are here

Overview

Add

Use mulle-sde to add MulleWebServer to your project:

mulle-sde add github:MulleWeb/MulleWebServer

Install

Install with mulle-sde

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

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

Manual Installation

Install the requirements:

Requirements Description
MulleCivetWeb 🦊 HTTP Server for mulle-objc
MulleObjCJSMNFoundation 🌼 JSON support 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 MulleWebServer 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