Files
coder/coderd/coderd.go
Kyle Carberry afc2fa3b62 feat: Add Coder Daemon to serve the API (#18)
* feat: Add v1 schema types

This adds compatibility for sharing data with Coder v1. Since the tables are the same, all CRUD operations should function as expected.

* Add license table

* feat: Add Coder Daemon to serve the API

coderd is a public package which will be consumed by v1 to support running both at the same time. The frontend will need to be compiled and statically served as part of this eventually.

* Fix initial migration

* Move to /api/v2

* Increase peer disconnectedTimeout to reduce flakes on slow machines

* Reduce timeout again

* Fix version for pion/ice
2022-01-13 16:55:28 -06:00

32 lines
611 B
Go

package coderd
import (
"net/http"
"cdr.dev/slog"
"github.com/coder/coder/database"
"github.com/go-chi/chi"
"github.com/go-chi/render"
)
// Options are requires parameters for Coder to start.
type Options struct {
Logger slog.Logger
Database database.Store
}
// New constructs the Coder API into an HTTP handler.
func New(options *Options) http.Handler {
r := chi.NewRouter()
r.Route("/api/v2", func(r chi.Router) {
r.Get("/", func(w http.ResponseWriter, r *http.Request) {
render.JSON(w, r, struct {
Message string `json:"message"`
}{
Message: "👋",
})
})
})
return r
}