mirror of
https://github.com/coder/coder.git
synced 2025-07-01 16:07:26 +00:00
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
This commit is contained in:
31
coderd/coderd.go
Normal file
31
coderd/coderd.go
Normal file
@ -0,0 +1,31 @@
|
||||
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
|
||||
}
|
Reference in New Issue
Block a user