GithubHelp home page GithubHelp logo

elemefe / restc Goto Github PK

View Code? Open in Web Editor NEW
1.4K 51.0 113.0 505 KB

A server-side middleware to visualize REST requests.

Home Page: https://elemefe.github.io/restc/

License: MIT License

HTML 86.13% JavaScript 12.37% PHP 1.49%

restc's Introduction

restc

CircleCI (all branches)

中文文档

Introduction

restc is an HTTP server middleware, aiming to enhance debugging experience on RESTful APIs.

It can be easily integrated with popular HTTP frameworks. You will see:

  • formatted JSON responses in the browser
  • a debug panel with which you can send GET, POST, PUT, PATCH and DELETE requests directly in the browser

You can even share a request by sharing its URL directly to others and everything will be automatically filled in the panel.

Getting Started

npm install --save restc

Use the middleware

const restc = require('restc');
// for express
app.use(restc.express());
// for koa
app.use(restc.koa());
// ...and koa2
app.use(restc.koa2());
// for hapi
server.register(restc.hapi)
// for hapi of legacy version
server.register([{
  register: restc.hapiLegacy
}], (err) => {
  if (err) {
    throw err
  }
})

restc's People

Contributors

cattail avatar cloverstd avatar dependabot[bot] avatar lujjjh avatar maysnow avatar qingwei-li avatar yanagieiichi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

restc's Issues

KOA2+webpack middleware +restc 运行问题

webpack middleware与restc搭配一起运行,restc打开接口地址,直接提示下载,无法显示页面,response返回的content type 并不是txt/html 。

后面直接修改源代码,重新设定了响应的类型,之后正常

Display issue on project website

Hi, I have some issue to read project website : many font character are not available in my locale (en_US) and with my fontset, as you can see below
screen shot 2016-11-26 at 09 50 33-fullpage

Headers with the same keys are combined

For example, if the response header contains:

Vary: foo
Vary: bar

restc will transform it into:

Vary: foo, bar

However, the two Varys should not be combined here.

Since getAll() is deprecated and get() returns a combined string instead of an array, this issue may be not easy to solve.

Content-Disposition parsing issue

Currently, restc only recognizes the following form of Content-Disposition:

Content-Disposition: ...; filename="foo.bar"

Thus, the filenames of some attachments may be unexpectedly dropped.

eggjs中使用不生效

你好,在eggjs中添加restc中间件,执行了但是并没有生效,请问是什么原因?代码是egg中写的中间件代码:
wechatimg24

按照demo引入

写入 res.set('Content-Type', 'application/octet-stream')后
postman没问题,浏览器打开,直接下载一个文件后缀为dms

只应用于 API

今天第一次用,发现页面也成为了 restc 的页面, 所以有没有一些选项能让我指定只针对某些规则的 url . 或者其他的方式可以绕过不应该转变为 restc 的页面

我目前是这么做的:

if (DEVELOPMENT) {
    app.use(async (ctx, next) => {
        if (ctx.url.indexOf('/api') !== -1) {
            return restc.koa2()(ctx, next)
        }
        return next()
    })
}

301/302 redirect page

Says we currently have an API redirects user to another page:

Request --> API --> PageA

restc send a request from frontend with fetch instead of jumping page which breaks the process, currently I have to disable restc on prod env.

2017-03-27 10 52 25

thanks in advance

在nginx中引入,调试php接口不起作用

nginx config

server {
    listen 8000;

    root /home/restc;
    index index.php index.html index.htm;

    location / {
        add_header Vary Accept;
        if ($http_accept ~* "text/html") {
                rewrite ^.*$ / break;
                proxy_pass https://restc.faas.ele.me;
        }
    }

    include enable-php.conf;
}

php file

echo '{"hello":"json"}';

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.