{"id":15394253,"url":"https://github.com/xyproto/mooseware","last_synced_at":"2025-04-15T23:53:13.837Z","repository":{"id":20111666,"uuid":"23381409","full_name":"xyproto/mooseware","owner":"xyproto","description":":skull: Skeleton for writing a middleware handler","archived":false,"fork":false,"pushed_at":"2020-01-31T14:04:32.000Z","size":25,"stargazers_count":47,"open_issues_count":0,"forks_count":6,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-12T13:22:48.364Z","etag":null,"topics":["example","go","middleware","negroni","negroni-middleware-handler"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xyproto.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":"2014-08-27T07:48:37.000Z","updated_at":"2024-05-23T13:38:05.000Z","dependencies_parsed_at":"2022-07-21T19:48:36.834Z","dependency_job_id":null,"html_url":"https://github.com/xyproto/mooseware","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmooseware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmooseware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmooseware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyproto%2Fmooseware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyproto","download_url":"https://codeload.github.com/xyproto/mooseware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173061,"owners_count":21224481,"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":["example","go","middleware","negroni","negroni-middleware-handler"],"created_at":"2024-10-01T15:22:49.058Z","updated_at":"2025-04-15T23:53:13.821Z","avatar_url":"https://github.com/xyproto.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mooseware\n=========\n\n[![Build Status](https://travis-ci.com/xyproto/mooseware.svg?branch=master)](https://travis-ci.com/xyproto/mooseware)\n\nSimple example/skeleton code for writing a middleware handler.\n\nMiddleware example\n------------------\n\n~~~ go\npackage moose\n\nimport (\n\t\"log\"\n\t\"net/http\"\n)\n\ntype Middleware struct {\n\tmoose bool\n}\n\n// Middleware is a struct that has a ServeHTTP method\nfunc NewMiddleware() *Middleware {\n\treturn \u0026Middleware{true}\n}\n\n// The middleware handler\nfunc (l *Middleware) ServeHTTP(w http.ResponseWriter, req *http.Request, next http.HandlerFunc) {\n\t// Log moose status\n\tlog.Printf(\"MOOSE: %v\\n\", l.moose)\n\n\t// Call the next middleware handler\n\tnext(w, req)\n}\n~~~\n\nUsage\n-----\n\n~~~ go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/urfave/negroni\"\n\t\"github.com/xyproto/mooseware\"\n)\n\nfunc main() {\n\tmux := http.NewServeMux()\n\n\tmux.HandleFunc(\"/\", func(w http.ResponseWriter, req *http.Request) {\n\t\tfmt.Fprint(w, \"Bafflesnark!\")\n\t})\n\n\tn := negroni.Classic()\n\n\t// Moose status\n\tn.Use(moose.NewMiddleware())\n\n\t// Handler goes last\n\tn.UseHandler(mux)\n\n\t// Serve\n\tn.Run(\":3000\")\n}\n~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fmooseware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyproto%2Fmooseware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyproto%2Fmooseware/lists"}