zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    LINUX挂接移动硬盘
    LINUX挂接光盘镜像文件
    Parted:2T以上磁盘分区工具(LINUX挂载2T以上磁盘)
    LINUX文件系统操作命令
    linux 文件类型的颜色
    LINUX常用操作命令和命令行编辑快捷键
    telnet- Linux必学的60个命令
    Netstat- Linux必学的60个命令
    linux服务之maven
    PHP 设计模式 笔记与总结(4)PHP 链式操作的实现
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9584470.html
Copyright © 2011-2022 走看看