1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- /*
- * Rufs - Remote Union File System
- *
- * Copyright 2017 Matthias Ladkau. All rights reserved.
- *
- * This Source Code Form is subject to the terms of the MIT
- * License, If a copy of the MIT License was not distributed with this
- * file, You can obtain one at https://opensource.org/licenses/MIT.
- */
- /*
- Package api contains the REST API for RUFS.
- /about
- Endpoint which returns an object with version information.
- {
- api_versions : List of available API versions e.g. [ "v1" ]
- product : Name of the API provider (RUFS)
- version: : Version of the API provider
- }
- */
- package api
- import (
- "encoding/json"
- "net/http"
- "devt.de/krotik/rufs/config"
- )
- /*
- EndpointAbout is the about endpoint definition (rooted). Handles about/
- */
- const EndpointAbout = APIRoot + "/about/"
- /*
- AboutEndpointInst creates a new endpoint handler.
- */
- func AboutEndpointInst() RestEndpointHandler {
- return &aboutEndpoint{}
- }
- /*
- aboutEndpoint is the handler object for about operations.
- */
- type aboutEndpoint struct {
- *DefaultEndpointHandler
- }
- /*
- HandleGET returns about data for the REST API.
- */
- func (a *aboutEndpoint) HandleGET(w http.ResponseWriter, r *http.Request, resources []string) {
- data := map[string]interface{}{
- "product": "RUFS",
- "version": config.ProductVersion,
- }
- // Write data
- w.Header().Set("content-type", "application/json; charset=utf-8")
- ret := json.NewEncoder(w)
- ret.Encode(data)
- }
|