Code Monkey home page Code Monkey logo

Comments (7)

StefH avatar StefH commented on July 30, 2024 1

@jrestall ; the NuGet updated at https://www.nuget.org/packages/WireMock.Net/

from wiremock.net.

StefH avatar StefH commented on July 30, 2024

Sounds ok.

Method will be like:

IResponseBuilder WithBodyFromFile([NotNull] string filename, bool cache =true);

from wiremock.net.

StefH avatar StefH commented on July 30, 2024

@jrestall I've added some code, can you maybe do a quick review before I create a new NuGet ?

Changed code found at cbe6a0a

from wiremock.net.

jrestall avatar jrestall commented on July 30, 2024

Thanks for the amazingly quick turn around @StefH.

I have three questions,

  1. Can we also support relative paths where it defaults to a files directory as in WireMock. So passing path/to/myfile.xml could resolve to {some dir path}__admin/files/path/to/myfile.xml or similar?

  2. Would the following JSON configuration work that uses a BodyAsFile property?

{
  "Guid": "791a3f31-6946-4ce7-8e6f-0237c7443275",
  ...
  "Response": {
    "StatusCode": 404,
    "BodyAsFile ": "path/to/myfile.xml" 
  }
}
  1. A FileWatcher might be easier to use than having to specify whether each file is cached or not. Cache by default and clear the cache if a file is changed?

from wiremock.net.

StefH avatar StefH commented on July 30, 2024

1] This is possible I think.

2] JSONs could be:

{
        "Guid": "5c5b769a-7cfe-44bd-9801-a4e5fcf9bfc5",
        "Priority": 0,
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/file"
                    }
                ]
            },
            "Methods": [
                "get"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsFile": "c:\\temp\\x.json",
            "BodyAsFileIsCached": false,
            "UseTransformer": false,
            "Headers": {}
        }
    }

OR

    {
        "Guid": "55631924-791a-419e-928f-b735e312ab99",
        "Priority": 0,
        "Request": {
            "Path": {
                "Matchers": [
                    {
                        "Name": "WildcardMatcher",
                        "Pattern": "/filecache"
                    }
                ]
            },
            "Methods": [
                "get"
            ]
        },
        "Response": {
            "StatusCode": 200,
            "BodyAsBytes": "ew0KICAiaGkiOiAidGVzdCINCn0=",
            "BodyAsFileIsCached": true,
            "UseTransformer": false,
            "Headers": {}
        }
    }

3] I'll take a look....

from wiremock.net.

StefH avatar StefH commented on July 30, 2024

3]
My idea is that you would cache small files or files which need to be served very fast.

Other files (big files) could increase the memory from a running WireMock too much, so for these files I would use the non-cached version.

from wiremock.net.

jrestall avatar jrestall commented on July 30, 2024

Thanks @StefH, that makes sense. Again thank you so much for the quick turn-around on these enhancements.

from wiremock.net.

Related Issues (20)

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.