Commit a51ea995 authored by Jakob Moser's avatar Jakob Moser
Browse files

Shorten API, prepare for deployment

parent 6a6afa94
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -122,10 +122,8 @@ The code itself sends HTTPS requests to the different services to see if they ar
The `.htaccess` files are configuration for the Apache webserver:

* `api/.htaccess` redirects every request to `/api` to `/api/v1` (so you can enter https://status.fsco.li/api in your browser and are automatically directed to https://status.fsco.li/api/v1). This is just a comfort feature.
* `api/v1/.htaccess` is more complex: It rewrites every request ...
  * ... to `/api/v1/services` to go to `/api/v1/services.php`.
  * ... to `/api/v1/services/<host>` to go to `/api/v1/services.php?host=<host>`
  * This is necessary because we want to provide a true REST-API experience (where all the request URLs look like paths), but can only use single PHP files to build the application, which take their parameters using queries (e.g., `?host=<host>`).
* `api/v1/.htaccess` rewrites every request to `/api/v1/services` to go to `/api/v1/services.php`.
  * This is necessary because we want to provide a true REST-API experience (where all the request URLs look like paths), so we would like to avoid the `.php` suffix.

### Docker

+6 −29
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
openapi: 3.0.2
info:
    title: fscoli Status
    version: 0.0.1
    version: 1.0.0
    description: |
        Monitor the status of services of the Fachschaft Computerlinguistik, Universität Heidelberg
paths:
@@ -18,38 +18,16 @@ paths:
                                type: array
                                items:
                                    $ref: "#/components/schemas/Service"
                    description: Successful response - returns an array of `Service` entities.
                    description: Successful response, returns a list of all known services and their statuses.
            operationId: getServices
            summary: List all services
            description: Gets a list of all `Service` entities.
    /services/{host}:
        summary: Path used to manage a single service.
        description: ""
        get:
            responses:
                "200":
                    content:
                        application/json:
                            schema:
                                $ref: "#/components/schemas/Service"
                    description: Successful response - returns a single `Service`.
            operationId: getService
            summary: Get a service
            description: Gets the details of a single instance of a `Service`.
        parameters:
            - name: host
              description: "The host name, which uniquely identifies the service."
              schema:
                  type: string
              in: path
              required: true
            description: "Main endpoint of this API, returns a status report."
components:
    schemas:
        Service:
            title: Root Type for Service
            description:
                "A service. Has a name, is reachable at some url and can be up\
                \ or down."
                "A service. Has a name, a category, runs on a host and has a status"
            required:
                - status
                - name
@@ -62,15 +40,14 @@ components:
                    type: string
                    readOnly: true
                status:
                    description: The HTTP response code one get's when sending a simple HTTP GET request to the service.
                    description: The curl response code when sending a HTTPS GET request to the service. Usually the HTTP status code (e.g. 200, 404), in case of network errors, it might be a different code.
                    type: integer
                    readOnly: true
                host:
                    description: |-
                        The host name of the service.

                        This is not the URL, i.e. do not prefix this with a protocol (e.g. use example.com
                        and not https://example.com)
                        This is not the URL, i.e. do not prefix this with a protocol (e.g. `example.com` and not `https://example.com`)
                    type: string
                    readOnly: true
                category: