{"id":21865231,"url":"https://github.com/gildas/wess","last_synced_at":"2026-02-04T22:36:25.408Z","repository":{"id":180157590,"uuid":"663733764","full_name":"gildas/wess","owner":"gildas","description":"WEb Simple Server","archived":false,"fork":false,"pushed_at":"2025-11-04T03:23:52.000Z","size":184,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-30T22:36:43.852Z","etag":null,"topics":["go","golang","http-server","web"],"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/gildas.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-08T01:26:03.000Z","updated_at":"2025-11-04T03:21:46.000Z","dependencies_parsed_at":"2024-01-24T12:29:38.209Z","dependency_job_id":"b94b5b32-3aba-4e88-817b-ae1579f8461e","html_url":"https://github.com/gildas/wess","commit_stats":null,"previous_names":["gildas/wess"],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/gildas/wess","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildas%2Fwess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildas%2Fwess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildas%2Fwess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildas%2Fwess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gildas","download_url":"https://codeload.github.com/gildas/wess/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gildas%2Fwess/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29098239,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-04T21:05:08.033Z","status":"ssl_error","status_checked_at":"2026-02-04T21:04:53.031Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["go","golang","http-server","web"],"created_at":"2024-11-28T04:15:15.511Z","updated_at":"2026-02-04T22:36:25.389Z","avatar_url":"https://github.com/gildas.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wess\n\n![GoVersion](https://img.shields.io/github/go-mod/go-version/gildas/wess)\n[![GoDoc](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go\u0026logoColor=white\u0026style=flat-square)](https://pkg.go.dev/github.com/gildas/wess)\n[![License](https://img.shields.io/github/license/gildas/wess)](https://github.com/gildas/wess/blob/master/LICENSE)\n[![Report](https://goreportcard.com/badge/github.com/gildas/wess)](https://goreportcard.com/report/github.com/gildas/wess)  \n\n![master](https://img.shields.io/badge/branch-master-informational)\n[![Test](https://github.com/gildas/wess/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/gildas/wess/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/gildas/wess/branch/master/graph/badge.svg?token=gFCzS9b7Mu)](https://codecov.io/gh/gildas/wess/branch/master)\n\n![dev](https://img.shields.io/badge/branch-dev-informational)\n[![Test](https://github.com/gildas/wess/actions/workflows/test.yml/badge.svg?branch=dev)](https://github.com/gildas/wess/actions/workflows/test.yml)\n[![codecov](https://codecov.io/gh/gildas/wess/branch/dev/graph/badge.svg?token=gFCzS9b7Mu)](https://codecov.io/gh/gildas/wess/branch/dev)\n\nWEb Simple Server\n\n## Running a WESS instance\n\n### Basics\n\nRunning a WESS instance is very easy, by default on port 80 all interfaces:\n\n```go\nfunc main() {\n  server := wess.NewServer(wess.ServerOptions{})\n  shutdown, stop, _ := server.Start(context.Background())\n  err = \u003c-shutdown\n}\n```\n\n`err` will contain the eventual errors when the server shuts down and `stop` is a `chan` that allows you to stop the server programmatically.\n\nOf course that server does not serve much...\n\nYou can change the port, give an address to listen to:\n\n```go\nserver := wess.NewServer(wess.ServerOptions{\n  Address: \"192.168.1.1\",\n  Port:    8000,\n})\n```\n\nYou can also overwrite the default handlers used when a route is not found or a method is not Allowed:\n\n```go\nserver := wess.NewServer(wess.ServerOptions{\n  Logger:                  log,\n  NotFoundHandler:         notFoundHandler(log),\n  MethodNotAllowedHandler: methodNotAllowedHandler(Options),\n})\n```\n\nIf you add a `ProbePort`, `wess` will also serve some _health_ routes for Kubernetes or other probe oriented environments. These following routes are available:\n\n- `/healthz/liveness`\n- `/healthz/readiness`\n\nYou can change the root path from `/healthz` with the `HealthRootPath` option:\n\n```go\nserver := wess.NewServer(wess.ServerOptions{\n  ProbePort:      32000,\n  HealthRootPath: \"/probez\",\n})\n```\n\n**Note:** If the probe port is the same as the main port, all routes are handled by the same web server. Otherwise, 2 web servers are instantiated.\n\n### Adding routes\n\nYou can add a simple route with `AddRoute` and `AddRouteWithFunc`:\n\n```go\nserver.AddRoute(\"GET\", \"/something\", somethingHandler)\nserver.AddRouteWithFunc(\"GET\", \"/somewhere\", somewhereFunc)\n```\n\nThe first method accepts a [http.Handler](https://pkg.go.dev/net/http#Handler) while the second accepts a [http.HandlerFunc](https://pkg.go.dev/net/http#HandlerFunc).\n\nHere is an embedded example:\n\n```go\nserver.AddRouteWithFunc(\"GET\", \"/hello\", func(w http.ResponseWriter, r *http.Request) {\n  log := logger.Must(logger.FromContext(r.Context())).Child(nil, \"hello\")\n\n  w.WriteHeader(http.StatusOK)\n  w.Header().Add(\"Content-Type\", \"text/plain\")\n  written, _ := w.Write([]byte(\"Hello, World!\"))\n  log.Debugf(\"Witten %d bytes\", written)\n})\n```\n\nFor more complex cases, you can ask for a [SubRouter](https://pkg.go.dev/github.com/gorilla/mux#Router):\n\n```go\nmain() {\n  // ...\n  APIRoutes(server.SubRouter(\"/api/v1\"), dbClient)\n}\n\nfunc APIRoutes(router *mux.Router, db *db.Client) {\n  router.Method(\"GET\").Path(\"/users\").Handler(GetUsers(db))\n}\n```\n\n(See the [vue-with-api](samples/vue-with-api/README.md) sample for a complete implementation)\n\n### Adding a frontend\n\nTo add a frontend, the easiest is to use [vite](https://vitejs.dev). You can also use [webpack](https://webpack.js.org). As long as you can bundle all the distribution files in the same folder.\n\nIn the folder you want to write your `wess` application, create the frontend instance (Here, using [Vue](https://vuejs.org). You can also use [react](https://react.dev)):\n\n```sh\nnpm create vite@latest frontent -- --template vue\n```\n\nor with [yarn](https://yarnpkg.com/):\n\n```sh\nyarn create vite frontend --template vue\n```\n\nDuring the development phase of the frontend, you should run the dev server directly from the frontend folder:\n\n```sh\ncd frontend\nnpm install\nnpm run dev\n```\n\nor with [yarn](https://yarnpkg.com/):\n\n```sh\ncd frontend\nyarn install\nyarn dev\n```\n\nOnce the frontend is done, build the project:\n\n```sh\nnpm run build\n```\n\nor with [yarn](https://yarnpkg.com/):\n\n```sh\nyarn build\n```\n\nAnd add a `wess` server in the parent folder of the frontend:\n\n```go\nvar (\n  //go:embed all:frontend/dist\n  frontendFS embed.FS\n)\n\nfunc main() {\n  server := wess.NewServer(wess.ServerOptions{\n    Port: 8080,\n  })\n  _ = server.AddFrontend(\"/\", frontendFS, \"frontend/dist\")\n  shutdown, stop, _ := server.Start(context.Background())\n  \u003c-shutdown\n}\n```\n\nThen, create a single binary that will contain the server and the frontend code:\n\n```sh\ngo build .\n```\n\nThat's it, you now have a single small executable file!\n\n## Running the samples\n\nThe `samples` folder contains a few examples of `wess` in action.\n\n- [samples/vue](samples/vue/README.md) contains a simple [Vue](https://vuejs.org) project\n- [samples/vue-with-api](samples/vue-with-api/README.md) contains a simple [Vue](https://vuejs.org) project that calls an API ran by `wess`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgildas%2Fwess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgildas%2Fwess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgildas%2Fwess/lists"}