Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonrichardson/butler
Serve content in a monadic style.
https://github.com/simonrichardson/butler
Last synced: 22 days ago
JSON representation
Serve content in a monadic style.
- Host: GitHub
- URL: https://github.com/simonrichardson/butler
- Owner: SimonRichardson
- License: mit
- Created: 2014-09-27T19:55:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-01-30T08:42:50.000Z (almost 10 years ago)
- Last Synced: 2024-06-21T05:58:35.257Z (5 months ago)
- Language: Go
- Size: 1.06 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
butler
======Serve content in a monadic style.
```go
request := Butler().
Get().
Path("/name/:id").
ContentType("application/json").
QueryInt("limit")response := Butler().
ContentType("application/json").
Content(output.HtmlEncoder{})listEmployees := Service(request, response).Then(func(args map[string]g.Any) g.Any {
loadAllEmployees := func(x int) g.Any {
return []g.Any{}
}
return loadAllEmployees(args["limit"].(int))
})server := Compile(listEmployees)
// You can also render the server to markdown, for up to
// date documentation
doc, _ := markdown.Output(server)
fmt.FPrintln(os.Stdout, doc)service := Remotely(server)("localhost", 80)
service.Run()
```### TODO
- [x] Markdown support
- [ ] Query parameters support#### Notes
- This is not idiomatic go and I don't care!