Skip to content

Web API

GOST can use the RESTful API to interact with the GOST process by starting the Web API service.

gost -L http://:8080 -api :18080

or

gost -L http://:8080 -api "user:pass@:18080?pathPrefix=/api&accesslog=true"
services:
- name: service-0
  addr: ":8080"
  handler:
    type: http
  listener:
    type: tcp
api:
  addr: :18080
  pathPrefix: /api
  accesslog: true
  auth:
    username: user
    password: pass
  auther: auther-0

You can also start the API service only, and then dynamically configure services and other components through the API.

gost -api :18080
api:
  addr: :18080
  pathPrefix: /api
  accesslog: true
  auth:
    username: user
    password: pass
  auther: auther-0

Path Prefix

The URL path prefix can be set via the pathPrefix property.

For example, the default path is http://localhost:18080/config, when pathPrefix is set to /api, it becomes http://localhost:18080/api/config.

Access Log

Use the accesslog property to enable the API access log. By default, no access log is output.

Authentication

Authentication uses HTTP Basic Auth.

Authentication information can be set through the auth or auther options. If the auther option is set, the auth option is ignored.

gost -api user:pass@:18080
api:
  addr: :18080
  auth:
    username: user
    password: pass
  auther: auther-0

Online Test

You can use online environment to test, or try it directly in swaggerUI below. For API documentation, please refer to API Documentation.

The GOST program has built-in swagger API documentation. If the Web API service is enabled locally, you can also use https://gost.run/swagger-ui/?url=http://localhost:18080/docs/swagger.yaml to try to configure the local service (this assumes that the local Web API service is running on port 18080).

Switch Scheme

The default scheme in SwaggerUI is HTTPS. If you want to test local services, you need to manually switch to HTTP.

Comments