{"id":25387101,"url":"https://github.com/pr47h4m/expresso","last_synced_at":"2025-06-13T20:35:18.243Z","repository":{"id":64692239,"uuid":"557855427","full_name":"Pr47h4m/expresso","owner":"Pr47h4m","description":"Fast, unopinionated, minimalist web framework for Go","archived":false,"fork":false,"pushed_at":"2025-02-14T08:26:51.000Z","size":44,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T06:51:18.676Z","etag":null,"topics":["fast","framework","go","hacktoberfest","lightweight"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/pr47h4m/expresso","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/Pr47h4m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-26T12:39:21.000Z","updated_at":"2025-02-14T08:26:49.000Z","dependencies_parsed_at":"2025-02-15T21:00:24.740Z","dependency_job_id":null,"html_url":"https://github.com/Pr47h4m/expresso","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/Pr47h4m/expresso","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pr47h4m%2Fexpresso","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pr47h4m%2Fexpresso/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pr47h4m%2Fexpresso/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pr47h4m%2Fexpresso/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pr47h4m","download_url":"https://codeload.github.com/Pr47h4m/expresso/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pr47h4m%2Fexpresso/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259716442,"owners_count":22900882,"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":["fast","framework","go","hacktoberfest","lightweight"],"created_at":"2025-02-15T11:26:20.123Z","updated_at":"2025-06-13T20:35:18.217Z","avatar_url":"https://github.com/Pr47h4m.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# expresso\n[![Go Reference](https://pkg.go.dev/badge/github.com/pr47h4m/expresso.svg)](https://pkg.go.dev/github.com/pr47h4m/expresso)\n\n## Fast, unopinionated, minimalist web framework for [Go](https://go.dev)\n\nExpresso is a web framework written in Go (GoLang).\n\n### Examples\n\n#### Hello World\n\n```(go)\npackage main\n\nimport \"github.com/pr47h4m/expresso\"\n\nfunc main() {\n\tapp := expresso.DefaultApp()\n\n\tapp.GET(\"/\", func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.Text{\n\t\t\tText: \"Hello World\",\n\t\t})\n\t})\n\n\tapp.ListenAndServe(\":80\")\n}\n```\n\n#### Basic Routing\n\n```(go)\npackage main\n\nimport \"github.com/pr47h4m/expresso\"\n\nfunc main() {\n\tapp := expresso.DefaultApp()\n\n\tapp.GET(\"/\", func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.Text{\n\t\t\tText: \"Hello World\",\n\t\t})\n\t})\n\n\tapp.POST(\"/\", func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.Text{\n\t\t\tText: \"Got a POST request\",\n\t\t})\n\t})\n\n\tapp.PUT(\"/user\", func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.Text{\n\t\t\tText: \"Got a PUT request as /user\",\n\t\t})\n\t})\n\n\tapp.DELETE(\"/user\", func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.Text{\n\t\t\tText: \"Got a DELETE request at /user\",\n\t\t})\n\t})\n\n\tapp.ListenAndServe(\":80\")\n}\n```\n\n#### Serve Static\n\n```(go)\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/pr47h4m/expresso\"\n)\n\nfunc main() {\n\tapp := expresso.DefaultApp()\n\n\tapp.ServeStatic(\"/public/*filepath\", http.Dir(\"public\"))\n\tapp.ServeStatic(\"/private/*filepath\", http.Dir(\"private\"))\n\n\tapp.ListenAndServe(\":80\")\n}\n```\n\n#### Web Service\n\n```(go)\npackage main\n\nimport (\n\t\"encoding/xml\"\n\t\"net/http\"\n\n\t\"github.com/pr47h4m/expresso\"\n)\n\ntype Repo struct {\n\tName string `json:\"name\"`\n\tURL  string `json:\"url\"`\n}\n\ntype User struct {\n\tName string `json:\"name\"`\n}\n\nvar (\n\tapiKeys = []string{\"foo\", \"bar\", \"baz\"}\n\trepos   = []Repo{\n\t\t{\n\t\t\tName: \"validation_chain\",\n\t\t\tURL:  \"https://github.com/pr47h4m/validation_chain\",\n\t\t},\n\t\t{\n\t\t\tName: \"expresso\",\n\t\t\tURL:  \"https://github.com/pr47h4m/expresso\",\n\t\t},\n\t}\n\tusers = []User{\n\t\t{\n\t\t\tName: \"pr47h4m\",\n\t\t},\n\t\t{\n\t\t\tName: \"jhanvi1061\",\n\t\t},\n\t}\n\tuserRepos = map[User][]Repo{\n\t\tusers[0]: repos,\n\t\tusers[1]: {},\n\t}\n)\n\nfunc main() {\n\tapp := expresso.DefaultApp()\n\n\tapp.GET(\"/api\", ValidateAPIKey, func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.HTML{\n\t\t\tHTML: \"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003eWeb Service in Go\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e\u003ch1\u003eWeb Service in Go\u003c/h1\u003e\u003ch3\u003e\\npowered by github.com/pr47h4m/expresso\u003c/h3\u003e\u003c/body\u003e\u003c/html\u003e\",\n\t\t})\n\t})\n\n\tapp.GET(\"/api/users\", ValidateAPIKey, func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.JSON{\n\t\t\t\"status\": \"200\",\n\t\t\t\"users\":  users,\n\t\t})\n\t})\n\n\tapp.GET(\"/api/repos\", ValidateAPIKey, func(ctx *expresso.Context) {\n\t\tctx.Send(expresso.JSON{\n\t\t\t\"status\": \"200\",\n\t\t\t\"repos\":  repos,\n\t\t})\n\t})\n\n\tapp.GET(\"/api/users/:name/repos\", ValidateAPIKey, func(ctx *expresso.Context) {\n\t\tusername := ctx.Params.ByName(\"name\")\n\n\t\tvar idx int = -1\n\n\t\tfor i := 0; i \u003c len(users); i++ {\n\t\t\tif users[i].Name == username {\n\t\t\t\tidx = i\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif idx != -1 {\n\t\t\tctx.Send(expresso.JSON{\n\t\t\t\t\"status\": \"200\",\n\t\t\t\t\"repos\":  userRepos[users[idx]],\n\t\t\t})\n\t\t} else {\n\t\t\tctx.Status(http.StatusNotFound).Send(expresso.JSON{\n\t\t\t\t\"status\": \"404\",\n\t\t\t\t\"error\":  \"username not found\",\n\t\t\t})\n\t\t}\n\t})\n\n\tapp.ListenAndServe(\":80\")\n}\n\nfunc ValidateAPIKey(ctx *expresso.Context) {\n\tkey := ctx.QueryParams.Get(\"api-key\")\n\n\tkeyMatched := false\n\n\tfor i := 0; i \u003c len(apiKeys); i++ {\n\t\tif apiKeys[i] == key {\n\t\t\tkeyMatched = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif keyMatched {\n\t\tctx.Next()\n\t} else {\n\t\tctx.Status(http.StatusUnauthorized).Formatted(ctx.RawRequest, expresso.Formatted{\n\t\t\tText: expresso.Text{\n\t\t\t\tText: \"401 - invalid api key\",\n\t\t\t},\n\t\t\tHTML: expresso.HTML{\n\t\t\t\tHTML: \"\u003chtml\u003e\u003chead\u003e\u003ctitle\u003e401 - invalid api key\u003c/title\u003e\u003c/head\u003e\u003cbody\u003e401 - invalid api key\u003c/body\u003e\u003c/html\u003e\",\n\t\t\t},\n\t\t\tJSON: expresso.JSON{\n\t\t\t\t\"status\": 401,\n\t\t\t\t\"error\":  \"invalid api key\",\n\t\t\t},\n\t\t\tXML: expresso.XML{\n\t\t\t\tXML: struct {\n\t\t\t\t\tXMLName xml.Name `xml:\"error\"`\n\t\t\t\t\tStatus  int      `xml:\"status\"`\n\t\t\t\t\tError   string   `xml:\"error\"`\n\t\t\t\t}{\n\t\t\t\t\tStatus: 401,\n\t\t\t\t\tError:  \"invalid api key\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tDefault: expresso.JSON{\n\t\t\t\t\"status\": 401,\n\t\t\t\t\"error\":  \"invalid api key\",\n\t\t\t},\n\t\t})\n\t}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr47h4m%2Fexpresso","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpr47h4m%2Fexpresso","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpr47h4m%2Fexpresso/lists"}