GithubHelp home page GithubHelp logo

4nth0 / golem Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 2.0 4.18 MB

From a single config file Golem start a mock server

License: MIT License

Go 96.35% Makefile 0.63% Smarty 2.05% Dockerfile 0.97%
api api-server mock qa qatools rest-api testing

golem's Introduction

Hi there 👋

golem's People

Contributors

4nth0 avatar pawndev avatar rewiko avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rewiko pawndev

golem's Issues

Handle CORS

Currently, Golem isn't able to handle CORS headers for the preflight request.
Preflight requests use the OPTIONS method to validate the ability of the third-party domain to fetch data.

CORS can be handled by service or by path.

By Service

port: "7171"
services: 
  - name: "Ping Server"
    http_config:
      cors: 
          origin: "*" | "${request.host}" | "https://mywebsite.com"
          methods: GET
      routes:
        "/ping": 
          body: '{"message": "pong!"}'

By Path

port: "7171"
services: 
  - name: "Ping Server"
    http_config:
      routes:
        cors: 
            origin: "*" | "${request.host}" | "https://mywebsite.com"
            methods: GET
        "/ping": 
          body: '{"message": "pong!"}'

Handle multiple HTTP methods for the same path

Currently, there is no way to have multiple methods for the same path.

Routes are declared with the following format :

routes:
  "/foo":
    body: "bar"

By default, the GET method is used.
Here the way to set the method :

routes:
  "/foo":
    method: "POST"
    body: "bar"

To handle multiple methods for the same route it can be interesting to use the following declaration format :

routes:
  "/foo":
    methods:
      "GET"
        body: "bar from get method"
      "POST"
        body: "bar from post method"

Make Golem able to auto-generate mocks

Golem is able to send pre-defined mocks but is unable to generate automatic mocks.
With the help of Faker solutions such as https://github.com/brianvoe/gofakeit Golem should generate mocks on the fly depending on YAML declaration of the expected mock scheme :

port: "8181"
services:
  - name: "Autogen Mocks"
    http_config:
      routes:
        "/posts":
          generate:
            scheme:
              "title":
                type: LoremIpsumSentence
                word_count: 3
              "content":
                type: LoremIpsumParagraph
                word_count: 3
              "views":
                type: Number
                min: 0
                max: 99
              "published":
                type: boolean

Déployer golem sur Dockerhub

Afin de mieux intégrer golem dans la stack des différents projets, il pourrait être utile de le dockeriser et de le rendre disponible sur Dockerhub. Cela permettrait par exemple d'appeler directement l'image Docker de golem dans un docker-compose pour mocker les projets en local.

Handle Method Not Allowed

Golem send the wrong status code when we call it with an unallowed HTTP method

port: "8989"
services:
  - name: "Service Sample"
    http_config:
      routes:
        "/foo":
          body: "bar"

If I try to call the service with an unallowed method I have a 200 Ok status code instead of 405 Method Not Allowed

curl -X POST http://127.0.0.1:8989/foo

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8989 (#0)
> POST /foo HTTP/1.1
> Host: 127.0.0.1:8989
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 25 Jun 2021 14:24:35 GMT
< Content-Length: 2
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host 127.0.0.1 left intact
Io* Closing connection 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.