-
-## Example
-
-
+## Usage
-## Web UI
+Windows
+```shell
+chcco install mokapi
+mokapi --providers-http-url https://petstore31.swagger.io/api/v31/openapi.json
+```
-
+MacOS
+```shell
+brew tap marle3003/tap
+brew install mokapi
+mokapi --providers-http-url https://petstore31.swagger.io/api/v31/openapi.json
+```
-## Usage
+Docker
+```shell
+docker run --env 'MOKAPI_Providers_Http_URL'='https://petstore31.swagger.io/api/v31/openapi.json' -p 80:80 -p 8080:8080 mokapi/mokapi:latest
+```
+Run a request
```shell
-docker run --env 'MOKAPI_Services_Swagger-Petstore_Config_Url'='https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.yaml' \
- --env 'MOKAPI_Services_Swagger-Petstore_Http_Servers[0]_Url'='http://:80' \
- -p 80:80 -p 8080:8080 \
- mokapi/mokapi:latest
+curl http://localhost/api/v31/pet/2 -H 'Accept: application/json'
```
+## Example
+
+
+
+## Dashboard
+
+
+
## Documentation
- [Get Started](https://mokapi.io/docs/guides/get-started/welcome)
@@ -68,3 +79,8 @@ docker run --env 'MOKAPI_Services_Swagger-Petstore_Config_Url'='https://raw.gith
- [Javascript API](https://mokapi.io/docs/javascript-api)
- [Examples & Tutorials](https://mokapi.io/docs/examples)
- [Blogs](https://mokapi.io/docs/blogs)
+
+
+
\ No newline at end of file
diff --git a/api/handler.go b/api/handler.go
index b31800869..dc03148bd 100644
--- a/api/handler.go
+++ b/api/handler.go
@@ -132,7 +132,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if isAsset(r.URL.Path) {
r.URL.Path = "/assets/" + filepath.Base(r.URL.Path)
- } else if filepath.Ext(r.URL.Path) == ".svg" || filepath.Ext(r.URL.Path) == ".png" {
+ } else if isImage(r.URL.Path) {
// don't change url
} else {
if len(h.path) > 0 || len(h.base) > 0 {
@@ -213,3 +213,13 @@ func writeJsonBody(w http.ResponseWriter, i interface{}) {
func isAsset(path string) bool {
return strings.Contains(path, "/assets/")
}
+
+func isImage(path string) bool {
+ str := filepath.Ext(path)
+ switch str {
+ case ".jpg", ".jpeg", ".png", ".svg":
+ return true
+ default:
+ return false
+ }
+}
diff --git a/api/handler_fileserver_test.go b/api/handler_fileserver_test.go
index a0c1e64e0..09312a15e 100644
--- a/api/handler_fileserver_test.go
+++ b/api/handler_fileserver_test.go
@@ -37,11 +37,6 @@ func TestHandler_FileServer(t *testing.T) {
try.HasHeader("Content-Type", "application/json"),
try.HasBody(`{"version":"","buildTime":""}`))
},
- fileServer: http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
- if request.URL.Path != "/index.html" {
- writer.WriteHeader(404)
- }
- }),
},
{
name: "request web app",
@@ -55,11 +50,6 @@ func TestHandler_FileServer(t *testing.T) {
h,
try.HasStatusCode(200))
},
- fileServer: http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
- if request.URL.Path != "/index.html" {
- writer.WriteHeader(404)
- }
- }),
},
{
name: "request web app",
@@ -73,11 +63,6 @@ func TestHandler_FileServer(t *testing.T) {
h,
try.HasStatusCode(200), try.BodyContains(`