{"id":16348511,"url":"https://github.com/devinus/fresh","last_synced_at":"2025-03-23T00:33:08.386Z","repository":{"id":1164737,"uuid":"1055606","full_name":"devinus/fresh","owner":"devinus","description":"The freshest Erlang web framework","archived":false,"fork":false,"pushed_at":"2011-02-17T18:45:02.000Z","size":727,"stargazers_count":33,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T03:45:55.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/devinus/fresh","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devinus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-11-05T22:45:34.000Z","updated_at":"2024-07-20T17:28:53.000Z","dependencies_parsed_at":"2022-08-16T12:20:54.645Z","dependency_job_id":null,"html_url":"https://github.com/devinus/fresh","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Ffresh","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Ffresh/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Ffresh/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devinus%2Ffresh/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devinus","download_url":"https://codeload.github.com/devinus/fresh/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245040235,"owners_count":20551297,"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-10-11T00:52:51.930Z","updated_at":"2025-03-23T00:33:08.062Z","avatar_url":"https://github.com/devinus.png","language":"Erlang","funding_links":[],"categories":["Micro Frameworks inspired by Sinatra (Other Languages)"],"sub_categories":[],"readme":"Fresh - The freshest Erlang web framework\n=========================================\n\n## What's so fresh about it?\n\nFresh is a Sinatra inspired Erlang web framework\nbased on Mochiweb that supports registering multiple\n\"web handlers\" that are dispatched to when you access\na Fresh instance. This allows you to theoretically\nserve sections of your website from multiple physically\nseparate computers. For instance, your main pages could\nserve from a server in Hong Kong while your user pages\nare served from Marfa, TX.\n\n## What's it look like?\n\n### example_web_handler.erl\n\n    -module(example_web_handler).\n    -behaviour(fresh_handler).\n\n    -export([dispatch_rules/0, 'GET'/2]).\n\n    dispatch_rules() -\u003e\n        fun('GET', [\"fresh\"], _Req) -\u003e true;\n           ('POST', [\"fresh\"], _Req) -\u003e true;\n           (_, _, _) -\u003e false end.\n\n    'GET'([\"fresh\"], _Req) -\u003e\n        \"So fresh!\".\n\n    'POST'([\"fresh\"], Req) -\u003e\n        Body = Req:recv_body(),\n        {json, [{ok, Body}]}.\n\n### example.erl\n\n    -module(example).\n    -behaviour(application).\n    -behaviour(supervisor).\n\n    -export([start/0, stop/0]).\n    -export([init/1, start/2, stop/1]).\n\n    start() -\u003e application:start(?MODULE).\n    stop()  -\u003e application:stop(?MODULE).\n\n    start(_Type, _Args) -\u003e\n        supervisor:start_link({local, example_sup}, ?MODULE, []).\n\n    stop(_State) -\u003e ok.\n\n    init([]) -\u003e\n        WebHandler = {example_web_handler,\n                      {fresh_handler, start_link, [example_web_handler]},\n                       permanent, 5000, worker, [fresh_handler]},\n        {ok, {{one_for_one, 10, 10}, [WebHandler]}}.\n\n### example.app\n\n    {application, example, [\n        {description, \"A Fresh example app\"},\n        {vsn, \"0.1\"},\n        {applications, [kernel, stdlib, sasl]},\n        {modules, [example, example_web_handler]},\n        {registered, [example]},\n        {mod, {example, []}}\n    ]}.\n\n## Options\n\n- `port`: port number, default: 7235\n\n## TODO\n\n- Allow custom error handlers (easy)\n- Register new dispatch rules during hot OTP upgrade (harder)\n- Statically analyze handler AST during registration to\n  create preliminary dispatch rules (hardest)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinus%2Ffresh","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevinus%2Ffresh","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevinus%2Ffresh/lists"}