{"id":13764106,"url":"https://github.com/ridgelines/fireball","last_synced_at":"2025-12-15T14:52:46.200Z","repository":{"id":57496986,"uuid":"63751802","full_name":"ridgelines/fireball","owner":"ridgelines","description":"Go web framework with a natural feel","archived":false,"fork":false,"pushed_at":"2018-10-03T21:26:08.000Z","size":1260,"stargazers_count":60,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-16T05:15:19.297Z","etag":null,"topics":["awesome-go","fireball","go","golang","handler","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/ridgelines.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":"2016-07-20T05:04:54.000Z","updated_at":"2024-04-07T00:01:12.000Z","dependencies_parsed_at":"2022-09-04T05:50:36.348Z","dependency_job_id":null,"html_url":"https://github.com/ridgelines/fireball","commit_stats":null,"previous_names":["zpatrick/fireball"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ridgelines/fireball","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridgelines%2Ffireball","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridgelines%2Ffireball/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridgelines%2Ffireball/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridgelines%2Ffireball/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ridgelines","download_url":"https://codeload.github.com/ridgelines/fireball/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ridgelines%2Ffireball/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27752897,"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","status":"online","status_checked_at":"2025-12-15T02:00:09.782Z","response_time":96,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["awesome-go","fireball","go","golang","handler","web"],"created_at":"2024-08-03T15:01:14.013Z","updated_at":"2025-12-15T14:52:46.156Z","avatar_url":"https://github.com/ridgelines.png","language":"Go","funding_links":[],"categories":["Web Frameworks"],"sub_categories":[],"readme":"# Fireball\n\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/zpatrick/fireball/blob/master/LICENSE)\n[![Go Report Card](https://goreportcard.com/badge/github.com/zpatrick/fireball)](https://goreportcard.com/report/github.com/zpatrick/fireball)\n[![Go Doc](https://godoc.org/github.com/zpatrick/fireball?status.svg)](https://godoc.org/github.com/zpatrick/fireball)\n\n\n## Overview\nFireball is a package for Go web applications. \nThe primary goal of this package is to make routing, response writing, and error handling as easy as possible for developers,  so they can focus more on their application logic, and less on repeated patterns. \n\n## Installation\nTo install this package, run:\n```bash\ngo get github.com/zpatrick/fireball\n```\n\n## Getting Started\nThe following snipped shows a simple \"Hello, World\" application using Fireball:\n```go\npackage main\n\nimport (\n  \"github.com/zpatrick/fireball\"\n  \"net/http\"\n)\n\nfunc index(c *fireball.Context) (fireball.Response, error) {\n  return fireball.NewResponse(200, []byte(\"Hello, World!\"), nil), nil\n}\n\nfunc main() {\n  indexRoute := \u0026fireball.Route{\n    Path: \"/\",\n    Handlers: fireball.Handlers{\n      \"GET\": index,\n    },\n  }\n\n  routes := []*fireball.Route{indexRoute}\n  app := fireball.NewApp(routes)\n  http.ListenAndServe(\":8000\", app)\n}\n```\n\nThis will run a new webserver at `localhost:8000`\n\n## Handlers\n[Handlers](https://godoc.org/github.com/zpatrick/fireball#Handler) perform the business logic associated with requests. \nHandlers take a [Context](https://godoc.org/github.com/zpatrick/fireball#Context) object and returns either a [Response](https://godoc.org/github.com/zpatrick/fireball#Response) or an error.\n\n### HTTP Response\nThe [HTTP Response](https://godoc.org/github.com/zpatrick/fireball#HTTPResponse) is a simple object that implements the [Response](https://godoc.org/github.com/zpatrick/fireball#Response) interface. \nWhen the Write call is executed, the specified Body, Status, and Headers will be written to the http.ResponseWriter.\n\nExamples:\n```go\nfunc Index(c *fireball.Context) (fireball.Response, error) {\n    return fireball.NewResponse(200, []byte(\"Hello, World\"), nil), nil\n}\n```\n\n```go\nfunc Index(c *fireball.Context) (fireball.Response, error) {\n    html := []byte(\"\u003ch1\u003eHello, World\u003c/h1\u003e\")\n    return fireball.NewResponse(200, html, fireball.HTMLHeaders), nil\n}\n```\n\n### HTTP Error\nIf a Handler returns a non-nil error, the Fireball Application will call its [ErrorHandler](https://godoc.org/github.com/zpatrick/fireball#App) function. \nBy default (if your Application object uses the [DefaultErrorHandler](https://godoc.org/github.com/zpatrick/fireball#DefaultErrorHandler)), the Application will check if the error implements the [Response](https://godoc.org/github.com/zpatrick/fireball#Response) interface. \nIf so, the the error's Write function will be called. \nOtherwise, a 500 with the content of err.Error() will be written. \n\nThe [HTTPError](https://godoc.org/github.com/zpatrick/fireball#HTTPError) is a simple object that implements both the [Error](https://golang.org/pkg/builtin/#error) and [Response](https://godoc.org/github.com/zpatrick/fireball#Response) interfaces. \nWhen the Write is executed, the specified status, error, and headers will be written to the http.ResponseWriter. \n\nExamples:\n```go\nfunc Index(c *fireball.Context) (fireball.Response, error) {\n    return nil, fmt.Errorf(\"an error occurred\")\n}\n```\n```go\nfunc Index(c *fireball.Context) (fireball.Response, error) {\n    if err := do(); err != nil {\n        return nil, fireball.NewError(500, err, nil)\n    }\n    \n    ...\n}\n```\n\n## Routing\n\n### Basic Router\nBy default, Fireball uses the [BasicRouter](https://godoc.org/github.com/zpatrick/fireball#BasicRouter) object to match requests to [Route](https://godoc.org/github.com/zpatrick/fireball#Route) objects.\nThe Route's Path field determines which URL patterns should be dispached to your Route. \nThe Route's Handlers field maps different HTTP methods to different [Handlers](https://godoc.org/github.com/zpatrick/fireball#Handler).\n\nYou can use `:variable` notation in the Path to match any string that doesn't contain a `\"/\"` character.\nThe variables defined in the Route's Path field can be accessed using the [Context](https://godoc.org/github.com/zpatrick/fireball#Context) object.\n\nExample:\n```go\nroute := \u0026Fireball.Route{\n  Path: \"/users/:userID/orders/:orderID\",\n  Methods: fireball.Handlers{\n    \"GET\": printUserOrder,\n  },\n}\n\nfunc printUserOrder(c *fireball.Context) (fireball.Response, error) {\n    userID := c.PathVariables[\"userID\"]\n    orderID := c.PathVariables[\"orderID\"]\n    message := fmt.Sprintf(\"User %s ordered item %s\", userID, orderID)\n    \n    return fireball.NewResponse(200, []byte(message), nil)\n}\n```\n\n### Static Routing\nThe built-in [FileServer](https://golang.org/pkg/net/http/#FileServer) can be used to serve static content.\nThe follow snippet would serve files from the `static` directory:\n```go\n  app := fireball.NewApp(...)\n  http.Handle(\"/\", app)\n\n  fs := http.FileServer(http.Dir(\"static\"))\n  http.Handle(\"/static/\", http.StripPrefix(\"/static\", fs))\n  \n  http.ListenAndServe(\":8000\", nil)\n```\n\nIf the application workspace contained:\n```go\napp/\n    main.go\n    static/\n        hello_world.txt\n```\n\nA request to `/static/hello_world.txt` would serve the desired file.\n\n\n# HTML Templates\nBy default, Fireball uses the [GlobParser](https://godoc.org/github.com/zpatrick/fireball#GlobParser) to render HTML templates. \nThis object recursively searches a given directory for template files matching the given glob pattern. \nThe default root directory is `\"views\"`, and the default glob pattern is `\"*.html\"`\nThe name of the templates are `path/from/root/directory` + `filename`. \n\nFor example, if the filesystem contained:\n```go\nviews/\n    index.html\n    partials/\n        login.html\n```\n\nThe templates names generated would be `\"index.html\"`, and `\"partials/login.html\"`.\nThe [Context](https://godoc.org/github.com/zpatrick/fireball#Context) contains a helper function, [HTML](https://godoc.org/github.com/zpatrick/fireball#Context.HTML), which renders templates as HTML.\n\nExample:\n```go\nfunc Index(c *fireball.Context) (fireball.Response, error) {\n    data := \"Hello, World!\"\n    return c.HTML(200, \"index.html\", data)\n}\n```\n\n# Decorators\n[Decorators](https://godoc.org/github.com/zpatrick/fireball#Decorator) can be used to wrap additional logic around [Handlers](https://godoc.org/github.com/zpatrick/fireball#Handler). \nFireball has some built-in decorators:\n* [BasicAuthDecorator](https://godoc.org/github.com/zpatrick/fireball#BasicAuthDecorator) adds basic authentication using a specified username and password\n* [LogDecorator](https://godoc.org/github.com/zpatrick/fireball#LogDecorator) logs incoming requests\n\nIn addition to Decorators, the [Before](https://godoc.org/github.com/zpatrick/fireball#App) and [After](https://godoc.org/github.com/zpatrick/fireball#App) functions on the [Application](https://godoc.org/github.com/zpatrick/fireball#App) object can be used to perform logic when the request is received and after the response has been sent. \n\n# Examples \u0026 Extras\n* [JSON](https://github.com/zpatrick/fireball/blob/master/examples/api/controllers/movie_controller.go#L49)\n* [Logging](https://github.com/zpatrick/fireball/tree/master/examples/blog/main.go#L15)\n* [Authentication](https://github.com/zpatrick/fireball/tree/master/examples/blog/main.go#L14)\n* [HTML Templates](https://github.com/zpatrick/fireball/blob/master/examples/blog/controllers/root_controller.go#L71)\n* [Redirect](https://godoc.org/github.com/zpatrick/fireball#Redirect)\n\n# License\nThis work is published under the MIT license.\n\nPlease see the `LICENSE` file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fridgelines%2Ffireball","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fridgelines%2Ffireball","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fridgelines%2Ffireball/lists"}