48 lines
1.1 KiB
Markdown
48 lines
1.1 KiB
Markdown
# Vinegar
|
|
|
|
### Vinegar is a simple web application framework written in Go.
|
|
|
|
## Features
|
|
Routing with support for static files, templates, APIs
|
|
Template rendering
|
|
Caching
|
|
Gzip compression
|
|
Custom error pages
|
|
Getting Started
|
|
Prerequisites
|
|
|
|
Go 1.18+
|
|
### Installation
|
|
```go get geniuscartel.xyz/vinegar```
|
|
|
|
### Usage
|
|
|
|
Create a config.json file to define routes and options
|
|
|
|
### Import Vinegar and create a new server instance:
|
|
```
|
|
import "geniuscartel.xyz/vinegar"
|
|
|
|
func main(){
|
|
server := vinegar.NewServer(config)
|
|
Add handlers for API routes:
|
|
api := server.NewApiRoute("/api")
|
|
api.Get(handleGet)
|
|
Start the server:
|
|
server.Start(":8080")
|
|
}
|
|
```
|
|
|
|
See the examples folder for more usage examples.
|
|
|
|
## Configuration
|
|
The config.json file defines the routes and options for Vinegar. It supports the following route types:
|
|
|
|
* static - Map a URL pattern to a static file or directory
|
|
* template - Render a Go template on a route
|
|
* api - Add API routes with custom handlers
|
|
* See config_example.json for a sample configuration file.
|
|
|
|
|
|
## License
|
|
Vinegar is closed source. Copyright 2023 David Tookey. All rights reserved |