mirror of
https://github.com/Luzifer/ots.git
synced 2025-07-20 21:28:49 -04:00
Implement attachment checking in CLI (#141)
This commit is contained in:
parent
34275baa2f
commit
9a530e1c66
16 changed files with 374 additions and 17 deletions
7
api.go
7
api.go
|
@ -39,6 +39,7 @@ func (a apiServer) Register(r *mux.Router) {
|
|||
r.HandleFunc("/create", a.handleCreate)
|
||||
r.HandleFunc("/get/{id}", a.handleRead)
|
||||
r.HandleFunc("/isWritable", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusNoContent) })
|
||||
r.HandleFunc("/settings", a.handleSettings).Methods(http.MethodGet)
|
||||
}
|
||||
|
||||
func (a apiServer) handleCreate(res http.ResponseWriter, r *http.Request) {
|
||||
|
@ -111,6 +112,10 @@ func (a apiServer) handleRead(res http.ResponseWriter, r *http.Request) {
|
|||
})
|
||||
}
|
||||
|
||||
func (a apiServer) handleSettings(w http.ResponseWriter, _ *http.Request) {
|
||||
a.jsonResponse(w, http.StatusOK, cust)
|
||||
}
|
||||
|
||||
func (a apiServer) errorResponse(res http.ResponseWriter, status int, err error, desc string) {
|
||||
errID := uuid.Must(uuid.NewV4()).String()
|
||||
|
||||
|
@ -124,7 +129,7 @@ func (a apiServer) errorResponse(res http.ResponseWriter, status int, err error,
|
|||
})
|
||||
}
|
||||
|
||||
func (apiServer) jsonResponse(res http.ResponseWriter, status int, response apiResponse) {
|
||||
func (apiServer) jsonResponse(res http.ResponseWriter, status int, response any) {
|
||||
res.Header().Set("Content-Type", "application/json")
|
||||
res.Header().Set("Cache-Control", "no-store, max-age=0")
|
||||
res.WriteHeader(status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue