Commit Graph

12 Commits

Author SHA1 Message Date
Joris Vink e98a4ddab5 Change how routes are configured in Kore.
Routes are now configured in a context per route:

route /path {
	handler handler_name
	methods get post head
	validate qs:get id v_id
}

All route related configurations are per-route, allowing multiple
routes for the same path (for different methods).

The param context is removed and merged into the route context now
so that you use the validate keyword to specify what needs validating.
2021-09-15 11:09:52 +02:00
Joris Vink f6cd16c567 Replace static/dynamic with a single option: route
Kore will automatically detect if a route is a dynamic or static one
so there is no need for the configuration options to differ anymore.
2019-11-15 08:11:02 +01:00
Joris Vink 46375303cb Allow multiple binds on new server directive. 2019-09-27 20:00:35 +02:00
Joris Vink 7350131232 Allow listening of tls/notls ports at the same time.
Before kore needed to be built with NOTLS=1 to be able to do non TLS
connections. This has been like this for years.

It is time to allow non TLS listeners without having to rebuild Kore.

This commit changes your configuration format and will break existing
applications their config.

Configurations now get listener {} contexts:

listen default {
	bind 127.0.0.1 8888
}

The above will create a listener on 127.0.0.1, port 8888 that will serve
TLS (still the default).

If you want to turn off TLS on that listener, specify "tls no" in that
context.

Domains now need to be attached to a listener:

Eg:
	domain * {
		attach	default
	}

For the Python API this kills kore.bind(), and kore.bind_unix(). They are
replaced with:

	kore.listen("name", ip=None, port=None, path=None, tls=True).
2019-09-27 12:27:04 +02:00
Joris Vink 548348f553 2018 2018-01-20 22:51:06 +01:00
Joris Vink fcc044af87 change all domain directives to * in examples. 2017-09-19 15:16:02 +02:00
Joris Vink 175b2e2c9b kore flavor -> kodev flavor 2017-03-06 23:18:16 +01:00
Joris Vink 3e84502235 Adjust examples after recent changes.
- New kodev tool generates config with server.pem/key.pem.
- Use proper formats for kore_log().
- Update to new websocket api.
2017-02-25 17:02:39 -08:00
Joris Vink c5ce707a91 Introduce build flavors.
Kore applications now get a build.conf which may contain different
build flavors. Each flavor can get its own cflags or ldflags.

This was in parts inspired by #106.

A new cli command has been added:
kore flavor

This command allows you to see all flavors and switch between them.
The kore build command now also takes a -v argument which if given
dumps the used CFLAGS and LDFLAGS out to stdout.

For existing applications the build.conf is automatically generated
next time you run kore build or kore run.

Also fixed a bug in the json_yajl example, sneaky change here.
2016-01-27 21:29:59 +01:00
Joris Vink a958627837 Unlink correct file in upload example. 2016-01-20 10:33:32 +01:00
Joris Vink d67b5aaa04 Properly do config for upload example 2016-01-18 11:51:44 +01:00
Joris Vink fcb86ddb8b Massive rework of HTTP layer.
This commit is a flag day, your old modules will almost certainly
need to be updated in order to build properly with these changes.

Summary of changes:

- Offload HTTP bodies to disk if they are large (inspired by #100).
  (disabled by default)
- The http_argument_get* macros now takes an explicit http_request parameter.
- Kore will now throw 404 errors almost immediately after an HTTP request
  has come in instead of waiting until all data has arrived.

API changes:

- http_argument_get* macros now require an explicit http_request parameter.
  (no more magic invokations).
- http_generic_404() is gone
- http_populate_arguments() is gone
- http_body_bytes() is gone
- http_body_text() is gone
- http_body_read() has been added
- http_populate_post() has been added
- http_populate_get() has been added
- http_file_read() has been added
- http_file_rewind() has been added
- http_file_lookup() no longer takes name, fname, data and len parameters.
- http_file_lookup() now returns a struct http_file pointer.
- http_populate_multipart_form() no longer takes an secondary parameter.

New configuration options:

- http_body_disk_offload:
	Number of bytes after which Kore will offload the HTTP body to
	disk instead of retaining it in memory. If 0 this feature is
	disabled. (Default: 0)

- http_body_disk_path:
	The path where Kore will store temporary HTTP body files.
	(this directory does not get created if http_body_disk_offload is 0).

New example:

The upload example has been added, demonstrating how to deal with file
uploads from a multipart form.
2016-01-18 11:30:22 +01:00