• restheart 基本使用


    restheart 是一个方便基于mongodb的restapi 开发框架

    参考项目 https://github.com/rongfengliang/restheart-docker-compose

    docker-compose 环境运行

    • docker-compose yaml 文件
    version: '3'
    networks:
       backend:
    services:
       restheart:
          image: softinstigate/restheart
          container_name: restheart
          depends_on:
             - mongodb
          networks:
             - backend
          ports:
             - "8080:8080"
          # volumes:
          # - ./etc:/opt/restheart/etc:ro
    
       mongodb:
          image: mongo:3.6
          container_name: restheart-mongo
          environment:
                MONGO_INITDB_ROOT_USERNAME: restheart
                MONGO_INITDB_ROOT_PASSWORD: R3ste4rt!
          command: --bind_ip_all --auth
          volumes:
             - ./data:/data/db
          networks:
             - backend
          ports:
            - "27017:27017"
    
    restheart配置:
    
    • 启动
    docker-compose up -d
    • 访问
    http://localhost:8080/browser/#/?hal=f

    基本操作

    • 创建数据库

      使用httpie 工具

    http -a 'admin:changeit' PUT localhost:8080/db desc='this is my first db created with restheart'
    
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: u5pxfezxze7mau2999yhjk60p4j1vnq864m5m05a711ool4x9
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T05:58:59.239Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 05:43:59 GMT
    Etag: 5b8e1b9f5c404500080d1634
    Keep-Alive: timeout=38
    X-Powered-By: restheart.org
    
    • 创建集合
    http -a 'admin:changeit' PUT localhost:8080/db/coll desc='my first collection created with restheart'
    
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: 148lrvqkmnl6k2mvxnoilpbv5p167xc3w7fqavbubvnsfekj3t
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T06:41:59.905Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 06:26:59 GMT
    Etag: 5b8e25b35c404500080d1636
    Keep-Alive: timeout=38
    X-Powered-By: restheart.org
    
    • 添加集合
    http -a 'admin:changeit' POST localhost:8080/db/coll name='RESTHeart' rating='cool'
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: 148lrvqkmnl6k2mvxnoilpbv5p167xc3w7fqavbubvnsfekj3t
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T06:43:40.028Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 06:28:40 GMT
    Etag: 5b8e26185c404500080d1637
    Keep-Alive: timeout=38
    Location: http://localhost:8080/db/coll/5b8e2618c5a8c63d6b2839cd
    X-Powered-By: restheart.org
    
    • 获取集合数据
    http -a 'admin:changeit' GET localhost:8080/db/coll

    参考资料

    https://restheart.org/learn/tutorial/
    https://github.com/rongfengliang/restheart-docker-compose

  • 相关阅读:
    js模板
    block,inline和inline-block概念和区别
    jquery parent和parents,children和find
    (CVE-2015-5254)ActiveMQ 反序列化漏洞复现
    办公系统致远OA漏洞
    CVE-2018-16509 GhostScript 沙箱绕过(命令执行)漏洞
    phpmyadmin-相关漏洞详解
    XXL-JOB(任务调度中心)-反弹getshell
    组策略(域和域服务的搭建)
    解决在NAT模式下物理机无法ping通虚拟机的问题
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9584470.html
Copyright © 2020-2023  润新知