Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/perbu/go-sqlite-http
non-oo reference http impl
https://github.com/perbu/go-sqlite-http
Last synced: about 2 months ago
JSON representation
non-oo reference http impl
- Host: GitHub
- URL: https://github.com/perbu/go-sqlite-http
- Owner: perbu
- Created: 2024-02-12T09:30:15.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-12T11:43:30.000Z (11 months ago)
- Last Synced: 2024-06-21T08:16:23.108Z (7 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Non-OO servers in Go
## Typical Go server
```go
package main
import (
"fmt"
"golang.org/x/tools/go/types/typeutil"
"net/http"
)type Server struct {
dependency database.Connection
}func NewServer(dep database.Connection) *Server {
return &Server{dependency: dep}
}func (s *Server) RootHandler(w http.ResponseWriter, r *http.Request) {
// do something with s.dependency:
s.dependency.Query("SELECT * FROM users")
fmt.Fprintf(w, "Hello, Users!")
}func main() {
dep := database.NewConnection()
s := NewServer(dep)
http.HandleFunc("/", s.RootHandler)
http.ListenAndServe(":8080", nil)
}```