{"id":13832230,"url":"https://github.com/abiosoft/hello-caddy","last_synced_at":"2025-06-13T05:32:13.389Z","repository":{"id":34036880,"uuid":"37799231","full_name":"abiosoft/hello-caddy","owner":"abiosoft","description":"Sample external middleware for Caddy","archived":false,"fork":false,"pushed_at":"2016-03-26T04:38:39.000Z","size":9,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T05:17:23.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"akrylysov/algnhsa","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abiosoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-21T06:24:48.000Z","updated_at":"2018-10-06T07:59:11.000Z","dependencies_parsed_at":"2022-07-29T19:39:51.997Z","dependency_job_id":null,"html_url":"https://github.com/abiosoft/hello-caddy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/abiosoft/hello-caddy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fhello-caddy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fhello-caddy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fhello-caddy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fhello-caddy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abiosoft","download_url":"https://codeload.github.com/abiosoft/hello-caddy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abiosoft%2Fhello-caddy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259589120,"owners_count":22880914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T10:01:56.253Z","updated_at":"2025-06-13T05:32:13.351Z","avatar_url":"https://github.com/abiosoft.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# hello\nSample add-on for [Caddy](http://caddyserver.com).\n\n## Depreciated\nUse the [caddydev](https://github.com/caddyserver/caddydev#create-a-skeleton-add-on) tool to generate skeleton app instead. More [here](https://github.com/caddyserver/caddydev#create-a-skeleton-add-on). \n\n### Quick Start\n`go get` this middleware\n\n```shell\n$ go get github.com/abiosoft/hello-caddy\n```\n\n`cd` into the source directory\n\n```shell\n$ cd $GOPATH/src/github.com/abiosoft/hello-caddy\n```\n\nRun [caddydev](https://github.com/caddyserver/caddydev) to start Caddy with your new middleware.\n\n```shell\n$ caddydev\nStarting caddy...\n0.0.0.0:2015\n```\n\nTest the middleware\n\n```\n$ curl localhost:2015\nHello, I'm a caddy middleware\n```\n\n### This is magic, how did it happen ?\nBy default, Caddy looks for [`Caddyfile`](https://caddyserver.com/docs/caddyfile) in the current directory and this repository contains a suitable one. **Note** our new directive `hello`.\n```conf\n0.0.0.0\n\nhello\n```\nThis repository also contains a [`config.json`](https://github.com/caddyserver/caddydev#1-configjson-file) file.\n```\n{\n  \"directive\" : \"hello\"\n}\n```\n\n#### Digging into the source, hello.go\nFirstly, Caddy initializes the middleware using a compatible [Setup function](https://godoc.org/github.com/mholt/caddy/caddy#SetupFunc). **Note** that the function name must be `Setup`.\n```go\nfunc Setup(c *setup.Controller) (middleware.Middleware, error) {\n\treturn func(next middleware.Handler) middleware.Handler {\n\t\treturn \u0026handler{}\n\t}, nil\n}\n```\n\nThen process requests using the middleware's [Handler](https://godoc.org/github.com/mholt/caddy/middleware#Handler). All that this middleware is doing is to write \"Hello, I'm a caddy middleware\".\n```go\nfunc (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) {\n\tw.Write([]byte(\"Hello, I'm a caddy middleware\"))\n\treturn 200, nil\n}\n```\n\nIt is not magic afterall ;).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fhello-caddy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabiosoft%2Fhello-caddy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabiosoft%2Fhello-caddy/lists"}