An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          


Gopher

# 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.