caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
58.44k stars 4.04k forks source link

Add embedding snippet of code to v2 README #2711

Closed ingenieroariel closed 4 years ago

ingenieroariel commented 5 years ago

Similar to:

package main

import (
    "github.com/caddyserver/caddy/v2/caddy/caddymain"

    // plug in plugins here, for example:
    // _ "import/path/here"
)

func main() {
    caddymain.Run()
}
mholt commented 5 years ago

🤔 That is already in the readme.

mholt commented 5 years ago

Oh, you meant the v2 readme.

There are no third-party plugins for v2 yet, so... what do you need this for? Are you writing one maybe? :smile:

ingenieroariel commented 5 years ago

It's an odd experiment I am writing to generate vector tiles and then serve them statically using caddy.

I need to use cors (and not sure which other plugins) while building from NixOS:

https://github.com/piensa/mileto/blob/master/default.nix#L29

I liked v2 because of the Pythonesque DSL to write Open Geospatial Consortium compliant indexing for spatial files.

-a

mholt commented 5 years ago

Cool, gotcha.

FYI, you can probably do what the cors plugin does simply with the relevant request matchers and the http.handlers.headers module.

I liked v2 because of the Pythonesque DSL to write Open Geospatial Consortium compliant indexing for spatial files.

I think you lost me here, a bit: Caddy 2 does feature a Starlark integration, is that what you are referring to? And I'd love to learn more about what you're building! Do you have any other details?

ingenieroariel commented 5 years ago

It's a bit early on my experiments but I can share more info.

Yes, I am referring to Starlak. I have been part of a project ( https://github.com/geonode/geonode ) for around ten years, we used Postgresql +GeoServer + Django + ... to let people upload Spatial files and create / share maps.

The main use case if for example serving a 400mb GeoJSON file of "Rivers in the USA" and being able to filter a singular river (think doing jq on an id and serving just 50kb). Or serving a 2GB composited drone or satellite image and being able to serve overviews or tiles for a particular place ( https://www.cogeo.org/ ). Another very important use case is to index a folder and provide metadata and available services: https://github.com/opengeospatial/WFS_FES/blob/master/core/openapi/ogcapi-features-1.yaml

We had lots of issues over the years related to "unreliable uploads, authentication, naive proxying" and now that standard bodies are trying to make newer versions more http-y I believe software like Caddy can be used as the glue to serve spatial files: https://medium.com/@cholmes/beyond-web-feature-services-part-2-b77aa89a9fc0

mholt commented 4 years ago

Instructions for building Caddy 2 with plugins were added to the readme and main.go a while ago; closing.