tonivade/zeromock

Add to the Readme an example with jbang

tonivade opened this issue · 1 comments

Zeromock and jbang allow to create mock servers quick and easy

//usr/bin/env jbang "$0" "$@" ; exit $?

//DEPS com.github.tonivade:zeromock-server:0.12.0

import static com.github.tonivade.zeromock.api.Matchers.get;
import static com.github.tonivade.zeromock.api.Handlers.ok;
import static com.github.tonivade.zeromock.server.MockHttpServer.listenAt;

public class HelloWorld {
  public static void main(String[] args) {
    listenAt(8101)
      .when(get("/hello")).then(ok("Hello World!"))
      .start();
  }
}

Also with kscript

#!/usr/bin/env kscript

//DEPS com.github.tonivade:zeromock-server:0.12.0

import com.github.tonivade.zeromock.api.Matchers.get
import com.github.tonivade.zeromock.api.Handlers.ok
import com.github.tonivade.zeromock.server.MockHttpServer.listenAt

listenAt(8101)
  .`when`(get("/hello")).then(ok("Hello World!"))
  .start()