{"id":14860798,"url":"https://github.com/sake92/sharaf","last_synced_at":"2026-04-14T20:01:30.554Z","repository":{"id":191921593,"uuid":"624213169","full_name":"sake92/sharaf","owner":"sake92","description":"Minimalistic Scala 3 web framework","archived":false,"fork":false,"pushed_at":"2026-04-12T16:23:25.000Z","size":2823,"stargazers_count":63,"open_issues_count":9,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-04-12T17:28:24.461Z","etag":null,"topics":["htmx","http","http-server","scala","scala3","webframework"],"latest_commit_sha":null,"homepage":"https://sake92.github.io/sharaf/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sake92.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["sake92"],"ko_fi":"sake92"}},"created_at":"2023-04-06T01:38:35.000Z","updated_at":"2026-04-12T16:07:14.000Z","dependencies_parsed_at":"2023-09-01T15:06:14.456Z","dependency_job_id":"1e4925c3-e5f8-4822-b210-4b6069107faa","html_url":"https://github.com/sake92/sharaf","commit_stats":{"total_commits":252,"total_committers":3,"mean_commits":84.0,"dds":0.007936507936507908,"last_synced_commit":"f50625725cf0994fed90f37d55a2cd512544e613"},"previous_names":["sake92/sharaf"],"tags_count":58,"template":false,"template_full_name":null,"purl":"pkg:github/sake92/sharaf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sake92%2Fsharaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sake92%2Fsharaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sake92%2Fsharaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sake92%2Fsharaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sake92","download_url":"https://codeload.github.com/sake92/sharaf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sake92%2Fsharaf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31812977,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"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":["htmx","http","http-server","scala","scala3","webframework"],"created_at":"2024-09-19T20:01:05.995Z","updated_at":"2026-04-14T20:01:30.547Z","avatar_url":"https://github.com/sake92.png","language":"Scala","readme":"\n# Sharaf :nut_and_bolt:\n\nYour new favorite, simple, intuitive, batteries-included scala3 web framework.\n\nDocumentation at https://sake92.github.io/sharaf/\n\nHello world example:\n```scala\n//\u003e using scala 3.7.3\n//\u003e using dep ba.sake::sharaf-undertow:0.17.0\n\nimport ba.sake.sharaf.*\nimport ba.sake.sharaf.undertow.UndertowSharafServer\n\nval routes = Routes {\n  case GET -\u003e Path(\"hello\", name) =\u003e\n    Response.withBody(s\"Hello $name\")\n}\n\nUndertowSharafServer(\"localhost\", 8181, routes).start()\n```\n\n## Cheatsheet\n\n### Route Matching\n\n```scala\n// matches /hello/world\ncase GET -\u003e Path(\"hello\", \"world\") =\u003e\n\n// matches/hello/:name where name is a dynamic String variable\ncase GET -\u003e Path(\"hello\", name) =\u003e\n\n// matches/hello/:id where id is a dynamic Int variable\ncase GET -\u003e Path(\"hello\", param[Int](id)) =\u003e\n\n// matches a GET or POST request to /hello\ncase (GET | POST) -\u003e Path(\"hello\") =\u003e\n\n// matches any path that starts with /hello, e.g. /hello/a/b/c\ncase GET -\u003e Path(\"hello\", segments*) =\u003e\n\n// matches/hello/:cloud where cloud is a dynamic Cloud enum variable\nenum Cloud derives FromPathParam:\n  case aws, gcp, azure\n...\ncase GET -\u003e Path(\"hello\", param[Cloud](cloud)) =\u003e\n\n// matches /hello/user_id_:userId where userId is a dynamic String variable\n// here we use a Regex extractor\nval userIdRegex = \"user_id_(\\\\d+)\".r\n...\ncase GET -\u003e Path(\"hello\", userIdRegex(userId)) =\u003e\n```\n\n### Handling Query Params\n\n```scala\n// raw map of query params: Map[String, Seq[String]]\nval qp = Request.current.queryParamsRaw\n\n// query params parsed into a case class\ncase class SearchParams(q: String, perPage: Int) derives QueryStringRW\nval qp = Request.current.queryParams[SearchParams]\n\n// query params parsed into a case class with validation\ncase class SearchParams(q: String, perPage: Int) derives QueryStringRW\nobject SearchParams {\n  given Validator[SearchParams] = Validator.derived[SearchParams].notBlank(_.q)\n}\nval qp = Request.current.queryParamsValidated[SearchParams]\n\n// query params parsed into a named tuple\nval qp = Request.current.queryParams[(q: String, perPage: Int)]\n\n// query params parsed into a named tuple with union type\nval qp = Request.current.queryParams[(id: Int | String)]\n\n// query params parsed into a union of named tuples\nval qp = Request.current.queryParams[(firstName: String) | (lastName: String)]\n```\n\n\n\n### Handling Form Data\n\n```scala\n// raw map of form data: SeqMap[String, Seq[FormValue]]\nval formData = Request.current.bodyFormRaw\n\n// form data parsed into a case class\ncase class SearchParams(q: String, perPage: Int) derives FormDataRW\nval formData = Request.current.bodyForm[SearchParams]\n\n// form data parsed into a case class with validation\ncase class SearchParams(q: String, perPage: Int) derives FormDataRW\nobject SearchParams {\n  given Validator[SearchParams] = Validator.derived[SearchParams].notBlank(_.q)\n}\nval formData = Request.current.bodyFormValidated[SearchParams]\n\n// form data parsed into a named tuple\nval formData = Request.current.bodyForm[(q: String, perPage: Int)]\n\n// form data parsed into a named tuple with union type\nval formData = Request.current.bodyForm[(id: Int | String)]\n\n// form data parsed into a union of named tuples\nval formData = Request.current.bodyForm[(firstName: String) | (lastName: String)]\n```\n\n\n### Handling JSON Data\n\n```scala\n// raw map of JSON data: JValue\nval jsonData = Request.current.bodyJsonRaw\n\n// JSON parsed into a case class\ncase class SearchParams(q: String, perPage: Int) derives JsonRW\nval jsonData = Request.current.bodyJson[SearchParams]\n\n// JSON parsed into a case class with validation\ncase class SearchParams(q: String, perPage: Int) derives JsonRW\nobject SearchParams {\n  given Validator[SearchParams] = Validator.derived[SearchParams].notBlank(_.q)\n}\nval jsonData = Request.current.bodyJsonValidated[SearchParams]\n\n// JSON parsed into a named tuple\nval jsonData = Request.current.bodyJson[(q: String, perPage: Int)]\n\n// JSON parsed into a named tuple with union type\nval jsonData = Request.current.bodyJson[(id: Int | String)]\n\n// JSON parsed into a union of named tuples\nval jsonData = Request.current.bodyJson[(firstName: String) | (lastName: String)]\n```\n\n### Returning HTML\n\n```scala\ncase GET -\u003e Path() =\u003e\n  Response.withBody(IndexView)\n...\n// use safe html\"\" interpolator\n// works very well in combo with HTMX\ndef IndexView =\n  html\"\"\"\n    \u003c!DOCTYPE html\u003e\n    \u003chtml lang=\"en\"\u003e\n    \u003cbody\u003e\n    \u003cdiv\u003e\n        \u003cp\u003eWelcome!\u003c/p\u003e\n        \u003ca href=\"/hello/Bob\"\u003eHello world\u003c/a\u003e\n    \u003c/div\u003e\n    \u003c/body\u003e\n    \u003c/html\u003e\n  \"\"\"\n```\n\n### Server Sent Events\n\n```scala\ncase GET -\u003e Path(\"sse-events\") =\u003e\n  val sseSender = SseSender()\n  new Thread(() =\u003e {\n    for i \u003c- 1 to 5 do\n      sseSender.send(\n        ServerSentEvent.Message(\n          data = html\"\"\"\u003cdiv\u003eevent${i}\u003c/div\u003e\"\"\".toString\n        )\n      )\n      Thread.sleep(1_000)\n    sseSender.send(ServerSentEvent.Done())\n  }).start()\n  Response.withBody(sseSender)\n```\n\n\n\n","funding_links":["https://github.com/sponsors/sake92","https://ko-fi.com/sake92"],"categories":["Table of Contents"],"sub_categories":["Web Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsake92%2Fsharaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsake92%2Fsharaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsake92%2Fsharaf/lists"}