https://github.com/sebastianmarines/go-webserver
A web server written from scratch using Go
https://github.com/sebastianmarines/go-webserver
golang http sockets
Last synced: about 1 year ago
JSON representation
A web server written from scratch using Go
- Host: GitHub
- URL: https://github.com/sebastianmarines/go-webserver
- Owner: sebastianmarines
- License: mit
- Created: 2022-12-16T20:20:40.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-17T20:58:46.000Z (over 3 years ago)
- Last Synced: 2025-03-24T05:53:24.501Z (about 1 year ago)
- Topics: golang, http, sockets
- Language: Go
- Homepage: https://pkg.go.dev/github.com/sebastianmarines/go-webserver
- Size: 46.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-webserver
A simple, lightweight web server built with Go.
# Features
- [x] Supports GET, POST, PUT, DELETE, and OPTIONS requests
- [x] Supports JSON and HTML responses
- [x] Supports custom routes
- [x] Supports for path parameters in routes
- [x] Supports for query parameters in routes
- [ ] Customizable error pages
- [ ] Support for static files
# Getting Started
To start using go-webserver, simply install the package and import it into your Go project:
`go get github.com/sebastianmarines/go-webserver`
Then, import the package and create a new server:
```go
package main
import web "github.com/sebastianmarines/go-webserver"
func main() {
server := web.NewWebserver()
server.Get("/", func(request web.Request) web.Response {
return web.HTMLResponse("
Hello World!
", 200, nil)
})
server.Get("/hello/:greeting", func(request web.Request) web.Response {
content := "Hello " + request.PathParams["greeting"] + "!
"
return web.HTMLResponse(content, 200, nil)
})
server.Start(":8080")
}
```
# Contributing
If you would like to contribute to go-webserver, please fork the repository and submit a pull request.
# License
go-webserver is licensed under the MIT License.