config.h

The config.h module represents runtime configuration options as outlined in Configuration. Refer to that document for more details on what each option means.

Build Options

MN_CMDLINE_MAX_FLAGS

Defaults to 16. The maximum number of flags that can be parsed.

MN_CMDLINE_MAX_ARITY

Defaults to 8. The maximum number of values any one flag can have.

MN_REQUEST_MAX_PATH_LEN

Defaults to 2048. The maximum supported length of any incoming URI including a trailing NUL terminator. Requests with longer URIs automatically receive an HTTP 414 URI Too Long response.

MN_REQUEST_MAX_CAPTURES

Defaults to 16. The maximum number of captures permitted in any route. Clients using a route with more captures than this value permits will automatically receive an HTTP 501 Not Implemented response.

MN_REQUEST_MAX_QUERY_PARAMS

Defaults to 24. The maximum number of query parameters permitted in any route. Clients specifying more query parameters than this value permits will automatically receive an HTTP 501 Not Implemented response.

API

typedef struct lua_State mn_lua_t

An alias to the lua_State object provided by Lua.

enum mn_event_loop

The event loop to use. Currently the only supported value is MN_EVENT_LOOP_POLL.

unsigned int MN_EVENT_LOOP_POLL = 0
struct mn_config

Configuration options supplied to the mn_server on initialization.

unsigned long long coro_pages

A reference to the COROUTINE_PAGES option.

enum mn_log_level log_level

A reference to the LOG_LEVEL option.

unsigned long port

A reference to the PORT option.

struct mn_status mn_config_load(
struct mn_config out[static const 1]
)

Loads the default configuration.

If successful, the out parameter must be cleaned up using mn_config_unload().

Parameters:
Returns:

An mn_status with value:
- MN_ERROR_NONE on success;
- MN_ERROR_CONFIG on failure.

Aborts:

If space for MN_REQUEST_MAX_CAPTURES could not be allocated.

struct mn_status mn_config_load_file(
struct mn_str const path,
struct mn_config out[static const 1]
)

Loads the default configuration and then applies any overridden configuration options as defined in the file at path.

If successful, the out parameter must be cleaned up using mn_config_unload().

Parameters:
  • path – The location of a lua file to execute.

  • out – The mn_config reference to load.

Returns:

An mn_status with value:
- MN_ERROR_NONE on success;
- MN_ERROR_CONFIG on failure.

Aborts:

If space for MN_REQUEST_MAX_CAPTURES could not be allocated.

struct mn_status mn_config_load_chunk(
char const chunk[static const 1],
struct mn_config out[static const 1]
)

Loads the default configuration and then applies any overridden configuration options as defined in chunk.

If successful, the out parameter must be cleaned up using mn_config_unload().

Parameters:
  • path – A lua chunk to execute.

  • out – The mn_config reference to load.

Returns:

An mn_status with value:
- MN_ERROR_NONE on success;
- MN_ERROR_CONFIG on failure.

Aborts:

If space for MN_REQUEST_MAX_CAPTURES could not be allocated.

void mn_config_unload(struct mn_config c[static const 1])

Unloads a configuration object.

Should be called once you are finished using a mn_config object that was successfully loaded by a call to mn_config_load(), mn_config_load_file() or mn_config_load_chunk().

Parameters:
  • c – The configuration to unload.