From 004094e7f19eea0b54ae86ff29befc1b08510caf Mon Sep 17 00:00:00 2001 From: shanaya-Gupta Date: Sun, 9 Nov 2025 07:14:29 +0000 Subject: [PATCH] fix: Resolve #55 - Get the name of the board --- internal/api/api.go | 16 ++++++++++++++++ internal/api/docs/openapi.yaml | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/internal/api/api.go b/internal/api/api.go index 08d31d84..5880f70e 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -101,3 +101,19 @@ func NewHTTPRouter( return mux } + + +func GetBoardNameHandler() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + // micro.GetBoardName() will be defined in internal/micro/micro.go as per plan + name := micro.GetBoardName() + response := map[string]string{"name": name} + if err := json.NewEncoder(w).Encode(response); err != nil { + http.Error(w, "Failed to encode response: "+err.Error(), http.StatusInternalServerError) + return + } + } +} + + mux.Handle("GET /v1/system/name", GetBoardNameHandler()) \ No newline at end of file diff --git a/internal/api/docs/openapi.yaml b/internal/api/docs/openapi.yaml index f2b3a999..ae6cc0c9 100644 --- a/internal/api/docs/openapi.yaml +++ b/internal/api/docs/openapi.yaml @@ -1669,3 +1669,24 @@ components: version: type: string type: object + + +/v1/system/name: + get: + description: Returns the name of the board. + operationId: getBoardName + responses: + "200": + content: + application/json: + schema: + properties: + name: + type: string + type: object + description: Successful response + "500": + $ref: '#/components/responses/InternalServerError' + summary: Get the board's name + tags: + - System \ No newline at end of file